-
AuthorPosts
-
9 April 2020 at 14:42 #8037
Picmicro675
ParticipantHello forum,
I'm doing some experiments to get a load cell reading. I have the module with HX711 and I was not able to get safe data.
The biggest problem is starting a program with a PIC. I took out a 16F877A and I would say that I should receive the data with a serial shift. I currently have something done via bit bang and should send the clock for 24 volt and put the result in a variable a 32 bit. The data sheet it tells me that it must clock for a number of times since 25 a 27, depending on the range chosen.
Then I'm still not sure how the result is. Maybe Theremino has some tricks up its sleeve. After all, all the sources are written for arduino and I was not lucky enough to find for a 16F. Because in fact programmers want to stay wide and use 32bit matrices and / or floats for their calculations.
Microchip's 14-bit MCUs aren't cut out for these things, since bank memory cannot be used.
So since I usually write with the Proton Basic, the only library you could try to convert should be this.
If you have some lights to add to my dark path, willingly to share the case.10 April 2020 at 10:35 #8041theremino
KeymasterHi Picmicro675,
if you can't read the ADC, this is not due to insufficient micro bits, but to some errors,
we read an ADC a 24 bit con un PIC a 16 bit and it took us months to get it to work well, but not for the missing bits.Unfortunately our ADC is an AnalogDevice, therefore completely different, so our code will be of little use
however it should be useful you download from this page:
MasterFirmware_V5.0The problems you have reading these things are of the following types:
1) Wrong initial settings
2) Timing while reading
3) Hardware errors
4) Mistakes in understanding what the data sheet saysSo I advise you to reread the paragraph carefully “Serial Interface” to page 4
translate it into Italian and try to understand it well, word by word,
if you can't read you probably do something different from what is written there
(which is actually quite confusing, I've read it several times and still can't understand some sentences)I saw that on page 8 of the data-sheet there is an example in C and it should be quite simple to translate it into Proton-basic.
Have you tried to write it down and see what it does?12 April 2020 at 17:01 #8067Picmicro675
ParticipantHi Ther
> Have you tried to write it down and see what it does?
Translated I have also translated it. I have also improved the case which hangs on waiting for the DOUT (given ready) it does not change. I put the timeout at least if there are unknown errors you can get away from them.Sub readHX711 Clear timed_out ' reset the flag Clear avrg ' average variable counter Clear cnti ' reset value Clear ADSK ' lowering the clock pin ' next instruction gives a little delay before reading the input Clear cntn ' reset value Repeat ' loop over the wanted samples While ADDO = 1 ' probing the data pin to wait the start If cnti < 250 Then ' counting a time-out in case the cell fails DelayUS 50 ' for one round Else ' if exceeds Set timed_out ' flag a no ready signal Return ' leave the subroutine End If Inc cnti ' keep counting track Wend ' end of wait ADD0 Clear coun ' resetting the variable for the result Clear cnti ' reset the counter Repeat ' counting for 24 bits Set ADSK ' ticking the serial clock coun = coun << 1 ' shift left the variable Clear ADSK ' reset the clock coun.0 = ADDO Inc cnti ' keep counting track Until cnti > 23 ' loop for the next bit Clear ADSK ' reset the clock (ending communication) @Nop ' a small delay Set ADSK ' reset the clock high avrg = avrg + coun - offset ' sum the sample to the average value Inc cntn Until cntn >= MAXSAMPLES coun = avrg / MAXSAMPLES ' calculate the average EndSub
For the record, here it is. I also added an average which is defined in the program header how many cycles to do (at the moment I have given 40, but we have the option to go up to 255).
Taking into account that the’ offset is to calculate the zero point which includes the tare value. Theoretically zero is at VCC / 2 and would be 2 ^ 23. For that less than that it will be negative.
I haven't done the physical tests yet, just a simulation and i have no idea exactly if they are rational values. I would be curious to understand what can be done with the GAIN which is then not read during 25 bit, I think. Rather it should give the information for the next cycle.
Anyway I have the PIC and arduino to do some tests, the only thing missing is the desire to put together a prototype. I will go for a while.I saw something of the source and you can see the use of the SPI for communication. For what I'm doing it just uses a bit banging (as in arduino for that matter) and you are comfortable with a frequency if you keep the clock within the limits described by the data sheet. Then the rest of the components and as the example of the data sheets and I took the module.
Thanks for the informations…
I just have to test myself
-
This reply was modified 3 years, 8 months ago by
Picmicro675.
-
This reply was modified 3 years, 8 months ago by
Picmicro675.
12 April 2020 at 19:16 #8070theremino
KeymasterThe phrase “I have the module with HX711 and I was not able to get safe data” he had deceived me and I thought I could not read due to some mistake.
instead (I hope this time I have understood it right) you're putting together the firmware but haven't tried it yet.Regarding the firmware I gave it a look and everything seems OK.
You've also paid attention to the details and it will probably work when you try it.If there are any problems write them here and I will try to help you,
but don't hope too much on me because i don't know those modules nor the PIC you use
and then it is difficult to do these things remotely, without seeing the signs etc.…13 April 2020 at 5:50 #8074Picmicro675
ParticipantThank you for your support.
Come PIC, there are no limits, it can range with a wide range of models. It only uses software and involves nothing more than two pins. Maybe I should check if the communication times are within the limits of 60 uS after the rising edge of the clock, otherwise the device is turned off.
For this there could also be a development for Theremino and make it a small routine to use with this interface. Not to mention that NAU instead 7802 which has an I2C interface. However, the latter is always 24bit.
Maybe you can approach it with SPI interface, with a uS of space for one bit, you get to the maximum 500 Kbit/s.13 April 2020 at 9:25 #8079theremino
KeymasterUnfortunately, adding such components to our system would also require modifying the HAL and would be too long a job compared to the advantages. We have already taken months to connect the Analog Device Adc24, that has 16 channels, and that in addition to load cells it can do everything..
However, both the HX711 and the NAU can be used 7802 with the theremino system, in a simple and economical way:
– First solution – Program an Arduiino Nano with the Arduino IDE and connect it to the PC with our ArduHAL application
– Second solution (wireless) – Program an ESP32 with the Arduino IDE and connect it to the PC with our IotHAL applicationThere are libraries ready for both the Nano and the ESP32
https://www.arduinolibraries.info/libraries/hx711-arduino-library
https://platformio.org/lib/show/7083/Adafruit%20NAU7802%20LibraryAnd from here we download our two applications
https://www.theremino.com/downloads/foundations#arduhal
https://www.theremino.com/downloads/foundations#iothal22 April 2020 at 15:11 #8392Picmicro675
Participant> We have already taken months to connect the Analog Device Adc24, that has 16 channels,
Well, i would say the module does the same job. A special output to switch off the load cell, when not in use, but then two 24bit ADC channels. Lo zero si pone a 12bit, in practice a value that half will be considered negative.
Then for your work, leaving the module alone, you could also use your ADC. With a respectable result. Then it is necessary to see if there are particular measures for stability and / or noise rejection.Another curiosity:
I used, for the first time, a 16F877A, it seems to me that it does not work. But I suspect the MCLR wants us held high. It does not seem to me that there is in the configuration the way to disable it. Am I right?
Oh well, then I do the rehearsals….22 April 2020 at 18:45 #8394theremino
KeymasterIn all PICs the MCLR must be kept high, otherwise they reset continuously.
Usually it is held high by connecting it to the positive with a resistor so that it can also be lowered if necessary.
However, it would appear that you can disable the MCLR function and use the PIN 3 come Digital I / O.To page 144 of the datasheet they write:
REGISTER 14-1: CONFIGURATION WORD (ADDRESS 2007h)(1)
bit 7 LVP: Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit
1 = RB3/PGM pin has PGM function; low-voltage programming enabled
0 = RB3 is digital I/O, HV on MCLR must be used for programmingThen, if I understand correctly, it would be enough to lower the BIT to zero 7 registry to disable it.
Lower the BIT to zero 7 of the configuration register must be done during programming
with the programmer I know (PicKit2) it would disable the “LowVoltage Programming”
with other programmers there should be a similar entry. -
This reply was modified 3 years, 8 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.