Hi Josh and other users,
I would like to trigger different waveforms on two channels of the state machine.
For the first channel, I would like to play a particular waveform in some states, and another in other states. On the second channel I would like the same, just with two different waveforms again.
Furthermore, I want these two channels to play their respective waveforms simultaneously during states.
I have already loaded these waveforms and have been trying to work with serial messages and trigger profiles, but I am unable to get it to work. There was a similar post by Claudina, but that solution does not work in my script (it gives me no errors, but bpod doesn't trigger any waves either).
Could you please give me suggestions on how to execute this?
Thanks a lot in advance,
Alex
05-21-2019, 08:02 PM
Thank you hi. I have problem also. Can not get more waveforms to play on channels of the BPod output module and not conistent was  . Is there more clear documentation? Thank you heavily,
Kim-Jul
(05-17-2019, 12:03 PM)Alex Wrote: Hi Josh and other users,
I would like to trigger different waveforms on two channels of the state machine.
For the first channel, I would like to play a particular waveform in some states, and another in other states. On the second channel I would like the same, just with two different waveforms again.
Furthermore, I want these two channels to play their respective waveforms simultaneously during states.
I have already loaded these waveforms and have been trying to work with serial messages and trigger profiles, but I am unable to get it to work. There was a similar post by Claudina, but that solution does not work in my script (it gives me no errors, but bpod doesn't trigger any waves either).
Could you please give me suggestions on how to execute this?
Thanks a lot in advance,
Alex
To clarify: this is my script for the triggerprofiles:
ValveSuction = ones(1,10000)*5; %>> List of voltages to be played
NoValveSuction = ones(1,10000)*0; %>> Instead of 'X' to stop all waveforms (interfering with miniscope), load new waveform containing only 0V
Base = ones(1,10000)*3.3;
Trigger = ones(1,10000)*0;
A.TriggerMode = 'Master'; %>> Overrides playback if new message comes
A.loadWaveform(1, ValveSuction);
A.loadWaveform(4, NoValveSuction);
A.loadWaveform(2, Base);
A.loadWaveform(3, Trigger);
% A.TriggerProfiles = [4 3 255 255; 4 2 255 255; 1 2 255 255; 255 255 255 255; 255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255;255 255 255 255]; (tried out of desperation)
% % A.TriggerProfiles(1:12) = [4 67 255 255; 4 66 255 255; 1 66 255 255]; (also tried this, since this looked similar to a previous post)
A.TriggerProfileEnable = 'On';
LoadSerialMessages(1, ['P' 0]);
LoadSerialMessages(2, ['P' 1]);
LoadSerialMessages(3, ['P' 2]);
% % LoadSerialMessages('WavePlayer1', {['P' 0], ['P' 1], ['P' 2]});
(And in statemachine the 'Waveplayer1' messages)
Alternative: I have also tried just playing two waveforms on channel 1 and 2, respectively. However, I can only get channel 1 to work (even when I switch the waveform):
ValveSuction = ones(1,10000)*5;
Trigger = ones(1,10000)*3.3; (also doesn't work with 3V)
A.TriggerMode = 'Master';
A.loadWaveform(1, ValveSuction);
A.loadWaveform(2, Trigger);
A.BpodEvents{1} = 'On';
LoadSerialMessages('WavePlayer1', ['P' 1 0], 1);
LoadSerialMessages('WavePlayer1', ['P' 2 1], 2);
OR
LoadSerialMessages('WavePlayer1', {['P' 1 0], ['P' 2 1]});
With in the statemachine {'Waveplayer1', 1} and {'Waveplayer1', 2} in their respective states (and 'X' when no waveforms need to be played)
05-22-2019, 01:16 PM
(This post was last modified: 05-22-2019, 01:17 PM by Josh.)
Hi Alex,
If you're using 'A' and not 'W', you're probably using the AudioPlayer module firmware, which you'd control with the AudioPlayer class.
However, from the rest of your code, it looks like you're using the WavePlayer firmware and WavePlayer class.
With WavePlayer, when you create trigger profiles, use '0' to indicate no waveform, not '255'.
TriggerProfiles is correctly initialized when you create an instance of the WavePlayer object - so you'd then use:
W.TriggerProfiles(1,: ) = [4 67 0 0];
W.TriggerProfiles(2,: ) = [4 66 0 0];
etc.
The bigger problem is probably with your use of LoadSerialMessages().
The correct syntax is:
LoadSerialMessages (MyDevice, MyMessage, MessageNumber)
OR
LoadSerialMessages(MyDevice, Cell array of all messages)
MyDevice can be either the physical port on the state machine (1-N) or the name of the device in the Bpod Console (e.g. WavePlayer1)
I hope this helps!
-Josh
(05-22-2019, 01:16 PM)Josh Wrote: Hi Alex,
If you're using 'A' and not 'W', you're probably using the AudioPlayer module firmware, which you'd control with the AudioPlayer class.
However, from the rest of your code, it looks like you're using the WavePlayer firmware and WavePlayer class.
With WavePlayer, when you create trigger profiles, use '0' to indicate no waveform, not '255'.
TriggerProfiles is correctly initialized when you create an instance of the WavePlayer object - so you'd then use:
W.TriggerProfiles(1,: ) = [4 67 0 0];
W.TriggerProfiles(2,: ) = [4 66 0 0];
etc.
The bigger problem is probably with your use of LoadSerialMessages().
The correct syntax is:
LoadSerialMessages (MyDevice, MyMessage, MessageNumber)
OR
LoadSerialMessages(MyDevice, Cell array of all messages)
MyDevice can be either the physical port on the state machine (1-N) or the name of the device in the Bpod Console (e.g. WavePlayer1)
I hope this helps!
-Josh
Hi Josh,
Thanks for the response!
I changed my script based on your comments, but the messages still do not play.
I've tried LoadSerialMessages('WavePlayer1', 1, 1), but this gives me an error.
The second option gives me no errors, but the waves are not generated either.
Could you please give me a precise example of what I should put at LoadSerialMessages?
Thanks!
Alex
05-23-2019, 05:18 AM
(This post was last modified: 05-23-2019, 05:19 AM by Josh.)
Hi Alex,
Try:
LoadSerialMessages('WavePlayer1', ['P' 3 0], 1);
and then in the Output Actions section of a state in your state machine description,
{'WavePlayer1', 1}
Please note that as per the interface, the second byte of the serial message (3) indicates which channels to play the waveform on, in binary - so decimal 3 = binary 11 (channels 1 and 2)
05-23-2019, 07:57 AM
(This post was last modified: 05-23-2019, 08:09 AM by Alex.)
(05-23-2019, 05:18 AM)Josh Wrote: Hi Alex,
Try:
LoadSerialMessages('WavePlayer1', ['P' 3 0], 1);
and then in the Output Actions section of a state in your state machine description,
{'WavePlayer1', 1}
Please note that as per the interface, the second byte of the serial message (3) indicates which channels to play the waveform on, in binary - so decimal 3 = binary 11 (channels 1 and 2)
Hi Josh,
Thank you for the quick response.
I changed the serial messages to:
LoadSerialMessages('WavePlayer1', ['P' 3 0], 1);
LoadSerialMessages('WavePlayer1', ['P' 3 1], 2);
LoadSerialMessages('WavePlayer1', ['P' 3 2], 3);
However, a problem I had earlier arose. Namely, the very last wave played as the first wave in the wrong state. In the other states, no waves were played and no other waves aside from the first wave (with output of third wave) played.
I don't know what is going wrong. Do you have any ideas?
Thanks!
Alex
(05-23-2019, 07:57 AM)Alex Wrote: (05-23-2019, 05:18 AM)Josh Wrote: Hi Alex,
Try:
LoadSerialMessages('WavePlayer1', ['P' 3 0], 1);
and then in the Output Actions section of a state in your state machine description,
{'WavePlayer1', 1}
Please note that as per the interface, the second byte of the serial message (3) indicates which channels to play the waveform on, in binary - so decimal 3 = binary 11 (channels 1 and 2)
Hi Josh,
Thank you for the quick response.
I changed the serial messages to:
LoadSerialMessages('WavePlayer1', ['P' 3 0], 1);
LoadSerialMessages('WavePlayer1', ['P' 3 1], 2);
LoadSerialMessages('WavePlayer1', ['P' 3 2], 3);
However, a problem I had earlier arose. Namely, the very last wave played as the first wave in the wrong state. In the other states, no waves were played and no other waves aside from the first wave (with output of third wave) played.
I don't know what is going wrong. Do you have any ideas?
Thanks!
Alex Edit:
Changing this to:
LoadSerialMessages('WavePlayer1', {['P' 3 0], ['P' 3 1], ['P' 3 2]});
Did manage to get the waveplayer to play in every state, but again only the first trigger profile played (whilst in the states I do refer to the 3 separately and actually use the first trigger profile only once).
LoadSerialMessages('WavePlayer1', {['P' 3 0], 1, ['P' 3 1], 2, ['P' 3 2], 3});
Plays only in states where I refer to trigger profile 1 or 3, but in reality only plays the former.
Hi Alex,
Sorry, I forgot you were using trigger profile mode.
If you use this instead, it should work:
LoadSerialMessages('WavePlayer1', ['P' 0], 1); % Message 1 = play trigger profile 0
LoadSerialMessages('WavePlayer1', ['P' 1], 2); % Message 2 = play trigger profile 1
LoadSerialMessages('WavePlayer1', ['P' 2], 3); % Message 3 = play trigger profile 3
(05-27-2019, 09:21 PM)Josh Wrote: Hi Alex,
Sorry, I forgot you were using trigger profile mode.
If you use this instead, it should work:
LoadSerialMessages('WavePlayer1', ['P' 0], 1); % Message 1 = play trigger profile 0
LoadSerialMessages('WavePlayer1', ['P' 1], 2); % Message 2 = play trigger profile 1
LoadSerialMessages('WavePlayer1', ['P' 2], 3); % Message 3 = play trigger profile 3
Hi Josh,
Thank you for the response.
I've tried it, but I'm still experiencing issues.
As a recap, this is my script thus far:
ValveSuction = ones(1,10000)*5;
NoValveSuction = ones(1,10000)*0;
Base = ones(1,10000)*0;
Trigger = ones(1,10000)*3.3;
W.TriggerProfileEnable = 'On';
W.loadWaveform(1, ValveSuction);
W.loadWaveform(4, NoValveSuction);
W.loadWaveform(2, Base);
W.loadWaveform(3, Trigger);
W.TriggerProfiles(1,: ) = [4 66 0 0];
W.TriggerProfiles(2,: ) = [4 67 0 0];
W.TriggerProfiles(3,: ) = [1 67 0 0];
LoadSerialMessages('WavePlayer1', ['P' 0], 1); % Message 1 = play trigger profile 0
LoadSerialMessages('WavePlayer1', ['P' 1], 2); % Message 2 = play trigger profile 1
LoadSerialMessages('WavePlayer1', ['P' 2], 3); % Message 3 = play trigger profile 3
Just to clarify: the first serial messages loads the first trigger profile (with 'P' 0), the second the second and the third the third right? Earlier you commented it was 0, 1, 3 instead. Is that a typo or am I misinterpreting the waveplayer inputs?
The main issue at the moment is that whenever I use {'Waveplayer1', 2} as an output action with these settings, the third waveform plays first, followed by the first waveform instead of just the second waveform. The other output actions do not elicit any reaction from bpod.
What should I change?
Cheers,
Alex
|