-
• #2
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'tAs it is, I think instead of sending 25 pulses (24+1) you're actually sending 48 (24*2).
Hope that helps!
-
• #3
Someone else just asked about the HX711, and there is a possibility that using normal JS code will be a bit too slow for it. If your code doesn't work, I posted some ideas here: http://forum.espruino.com/conversations/258182/#comment12991634
-
• #4
yes it's me.
sorry, I've mistaked on the other post. I'll post on this thread now.
I managed to have a 22microsecond pulse with digitalPulse(..,.., 1000/65000) for a 65khz freq.
digitalwrite alternance just makes a 10ms perior for high time, this is too long for hx711, we have a 50microsecond limit according to the specs for the clock.
I've checked with an oscillo.
I'll finish my hx711 javascript port and post it there. -
• #5
Gordon,
I have tried your minified code from the other thread and I am receiving and I am getting the following
>get() =169289 >get() =169350 >get() =169282 >get() =169263 >get() =169297
Does this appear reasonable? the load cell is currently laying on the table.
I can get a reading using digitalPulse but it is much larger at around 338642 and differs by a few hundred between readings.
Many thanks again...
-
• #6
Well, the fact that it only differs by a bit each time sounds good. It's a 24 bit number, so could give you anything up to 24 million. The fact it's 169k probably means it's basically unloaded.
I'd experiment by putting different stresses on it and seeing how it changes.
Also, 338642 / 2 = 169321 - so it seems like the digitalPulse code might be working too, although maybe you're reading one too many bits, which is pushing the value up. Personally I'd avoid digitalPulse though because the async-ness of it might make it less reliable. The SPI method is quite efficient too.
-
• #7
There's some code for this posted up in another thread now: http://forum.espruino.com/conversations/287046/#comment14322664
Hello,
I am trying to get the HX711 IC to work with espruino. I have had some issues with getting it to work and would be very grateful if someone could advise me. The datasheet can be found at
https://cdn.sparkfun.com/datasheets/Sensors/ForceFlex/hx711_english.pdf
My code so far:
I am trying to measure the torque from a bicycle by measuring tension of the chain. A load cell will be cantilevered off of the frame and a idler wheel will pull the chain up by around 10 deg. I am thinking that the force pulling the pulley down will be around 20% of the total force in the chain. I would then like to use the measurement to drive a electric motor.
I may also use it to weigh our fat cat...
Thank you in advance