![]() |
Pulse Train in python - Printable Version +- Forums (https://sanworks.io/forum) +-- Forum: Pulse Pal (https://sanworks.io/forum/forumdisplay.php?fid=3) +--- Forum: Software (https://sanworks.io/forum/forumdisplay.php?fid=8) +--- Thread: Pulse Train in python (/showthread.php?tid=895) |
Pulse Train in python - Bryce_ds - 07-27-2020 hello, i am currently implementing a pulse train with ten bursts of three 1ms pulses, 20ms apart. each burst 200ms apart my code is as follows: ## times to trigger (ten bursts of three 1ms pulses 20ms apart, each burst 200ms apart) pulseTimes = [0.000, 0.020, 0.040, 0.240, 0.260, 0.280, 0.480, 0.500, 0.520, 0.720, 0.740, 0.760, 0.960, 0.980, 1.000, 1.200, 1.220, 1.240, 1.440, 1.460, 1.480, 1.680, 1.700, 1.720, 1.920, 1.940, 1.960, 2.160, 2.180, 2.200] ## voltages for each trigger, PowerMag triggers on 5V voltages = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5] myPulsePal.sendCustomPulseTrain(1, pulseTimes, voltages) # Send arrays to PulsePal, as custom train 1 (of 2 possible) ## setoutputchannel 1 to use 1 ms pulses myPulsePal.programOutputChannelParam('phase1Duration', 1, 0.001) ## set output channel 1 to use custom pulse train 1 myPulsePal.programOutputChannelParam('customTrainID', 1, 1) print(pulseTimes) output>>[0.0, 400.0, 800.0, 4800.0, 5200.0, 5600.000000000001, 9600.0, 10000.0, 10400.0, 14400.0, 14800.0, 15200.0, 19200.0, 19600.0, 20000.0, 24000.0, 24400.0, 24800.0, 28800.0, 29200.0, 29600.0, 33600.0, 34000.0, 34400.0, 38400.0, 38800.0, 39200.0, 43200.0, 43600.0, 44000.0] These outputs are supposed to be converting the inputs in seconds to multiples of 100us if I understand the code correctly, however, the self.cycleFrequency = 20000; This means that it is actually converting my input times into multiples of 200us. can you please explain if this is correct? *edit: I now realize that the code is indeed translating to the correct time, but not multiples of 100us. it is multiples of 50us: 1s/20000 = 50us= .00005s; 400*50us = .02s. also is there a better way to implement this? pps. Are you planning to update to python 3.7 anytime soon? Thank you so much for this wonderful device, cheers, Bryce |