Lazarus
Programming => Embedded => Operating Systems => Embedded - AVR => Topic started by: ccrause on October 27, 2021, 09:57:28 pm
-
Prompted by this (https://forum.lazarus.freepascal.org/index.php/topic,56874.msg422697.html#msg422697) question regarding reading the HX711 ADC on Raspberry Pi, I thought it would be interesting to try this on an atmega328p (a.k.a. Arduino Uno). Since I bought an HX711 board a few years ago "just in case", this was a good excuse to solder some wires to the board and give it a test.
Code can be viewed on Github (https://github.com/ccrause/fpc-avr/blob/master/src/examples/HX711/readHX711.pp).
-
I think you might have been better appending that to the original thread.
OK, so it looks like that's bit-banging it rather than using e.g. SPI.
MarkMLl
-
I think you might have been better appending that to the original thread.
That refers to Linux on RPi, AVR code is a bit different. I will post a cross reference, then the OP can decide whether to look at this.
OK, so it looks like that's bit-banging it rather than using e.g. SPI.
It seemed easier to just start with bit-bang. At least reading the 3 data bytes should be possible over SPI, but on AVR the last 1 - 3 clock pulses used to configure the next conversion would need to be bit-banged. Maybe I'll test SPI sometime this weekend.
-
Code can be viewed on Github (https://github.com/ccrause/fpc-avr/blob/master/src/examples/HX711/readHX711.pp).
OK, so it looks like that's bit-banging it rather than using e.g. SPI.
Updated example so that a user can select between using bit-bang or SPI. Even using SPI to read the 3 data bytes, the configuration for the next conversion needs to be bit-banged because the SPI peripheral can only work with 8 bit chunks of data.
-
the SPI peripheral can only work with 8 bit chunks of data.
Bring back the 8523 :-)
...of course, that wouldn't really do the job, but broadly speaking it had more support for weird protocols than anything else known to man. Although I have a very vague recollection of an '80s device which could do everything from PWM waveform synthesis to Ethernet.
MarkMLl