Hi - I think one issue is that digitalPulse is asyncronous - the pulse happens in the background.
You might have more luck changing it to:
digitalWrite(sgSend,1);
digitalWrite(sgSend,0);
At 1uS pulses, the above will be fine (due to code execution speed it's very unlikely to ever exceed 1uS there :)
Also, as far as I can tell, the gain is selected by the number of clock pulses. I think (and this could be the main issue) the loop you have (for (var o=0; o<gain;o++)) should be after the main loop, not inside it. It's not quite indented right (where you read the bit) and that might have made you think the for loop had ended when it actually hadn't
As it is, I think instead of sending 25 pulses (24+1) you're actually sending 48 (24*2).
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi - I think one issue is that
digitalPulse
is asyncronous - the pulse happens in the background.You might have more luck changing it to:
At 1uS pulses, the above will be fine (due to code execution speed it's very unlikely to ever exceed 1uS there :)
Also, as far as I can tell, the gain is selected by the number of clock pulses. I think (and this could be the main issue) the loop you have (
for (var o=0; o<gain;o++)
) should be after the main loop, not inside it. It's not quite indented right (where you read the bit) and that might have made you think the for loop had ended when it actually hadn'tAs it is, I think instead of sending 25 pulses (24+1) you're actually sending 48 (24*2).
Hope that helps!