Thread Tools
Apr 04, 2014, 09:16 PM
Jack
jackerbes's Avatar
Thread OP
Today I found the attached file, it was a download from the Chinese language pages of the dfrobot people. They make a module similar to the one I am using that also uses the HX711 chip and a beam scale as the interface for a scale.

It contains instruction on building as scale and, assuming they have it right, I realized I had the beam sensor mounted wrong. I had the wrong end as the fixed base and I also had it upside down. So I revised my test setup to get it used the same way as they show.

A key information I found in the document was instructions for doing the zero adjustment. It said to do this:

"..Zero adjustment - Open the Hx711 library folder , and find the file Hx711.h, open it. Locate the statement void setScale(float scale = 1992.f);
You only need to adjust the number 1992 to find the appropriate value for weight scale. Save the h file, and upload the above code again..."

So I modified the Hx711.h file and after a few tries, had the scale reading right on the money when weighed a 10g scale calibration weight. I have two of those weights and when I put them both on the scale, it was still right on the money.

So I think it is a step forward. My basement shop is still pretty cold, we are still down to freezing every night here in coastal Maine but the days are getting warmer. The snow is melting, the Robins are bobbing on the lawns, and winter will soon be gone. And my shop will be a place where I spend more time...

Jack
Sign up now
to remove ads between posts
Apr 05, 2014, 08:58 AM
Jack
jackerbes's Avatar
Thread OP
OK, with the beam sensor turned over and swapped end to end as per the How To... doc, I am basically starting over on calibrating the weight sensor. The change is that the "1992.f" value in the Hx711..h file in the Arduino Hx711 library folder is being changed to get the display to display the weight of a known object right (a 10g scale calibration weight for starters).

I have two 10g weights and 220g and 306g lead bars I am using for testing.

With the value set to 1992.f I get the following:

Startup weight is 0.0 g (occasionally dropping to -0.0 g) and adding the 10g weight displays as -2.0 g

Adding a second 10g weight changes the value displayed to -4.0 g

I changed the value in the Hx711.h file from 1992.f to 396.f. (value found, through experimentation, to give a correct weight value)

With setScale = 396.f - startup weight varies from 0.0 g to -0.0 g, adding the 10g weight displays as -9.9g and stabilizes at -10.0 g after a few refreshes. Adding second 10g weight increases display to -19.9g

with setScale = 396.f - startup weight is -0.0 g
adding the 220g weight displays as 42149.0 g (a positive value)

After experimenting with different values I changed the 396.f value to 75872.f to see if the weight on the 220g bar would then be right

with setScale = 75872.f - startup weight varies from -0.0 g, or 0.0 g, or 0.00 g and adding the 220g weight displays as steady and stable 220.0 g

Flushed with success, I added the 306g weight on top of the 220g weight. And the reading changed from 220.0 g to 218.4 g

Removing both weights gets me back to the -0.0 g display, addiing a 10g weight gave a reading of -0.1 g and a second 10g weight did not change that.

Did several ower off and power on cycles and resets and results are staying consistent but with the 75872.f value, only the 220g weight is correct. Also tried it on external power instead of USB port power and it did exactly the same.

The weights I have and how they are displaying with
the statement: void setScale(float scale = 75872.f); are as follows:

10g = -0.1 g
2x10g = -0.1 g
220g = 220 g
306g = 219.5 g
306g + 220g (526g) = 218.4 g

So I'm off to study the Arduiono Cookbook for a while and hang around on the Arduino Forum and maybe google it a bit more.

I have renamed the Hx711.h file to Hx711_h.txt and attached it so anyone that wants can study the statements there.

And it goes without saying, anyone tha knows anything is welcome to chime in on this.

Jack
Apr 05, 2014, 11:52 AM
Registered User
Jack,
Thanks for posting your journey with this project. I just discovered it as I was looking at what people are doing with micro controllers in our hobby.

I'm just getting my feet wet with the ATmega series and have chosen to put pieces together using a prototyping kit from Protostack http://www.protostack.com/ rather than starting with Arduino boards and their shields. I have past experience with Assembly language programing of a Z80 and RCA1802 and feel comfortable with C so I chose to deal at the chip level and interfacing sensors and devices with it.

I have some startup hardware now but need to set up the software development environment (plan to use Eclipse, the AVR-Eclipse plugin and WinARV libraries). I should have more time in about 3 month when I plan to retire.

As an initial target project, I'd like to build a wind direction and speed indicator which can display current data on a two line LCD but so also store that data to an SD Card (uses the SPI interface). I'd like to see just how much turbulence there is when my planes get tossed around.

Glad to see you are having success and best wishes for more,
Alan
Last edited by Al Offt; Apr 09, 2014 at 07:10 AM. Reason: missing word
Apr 05, 2014, 02:03 PM
Jack
jackerbes's Avatar
Thread OP
Hi Alan,

I have had my first reliable and working Arduino board for about three days now. Had a couple of problems with the Freaduino UNO V1.8 board and finally gave up and ordered another one. I think I've found out the hard way that there are all kinds of good and bad copies being made.

And I'm new to the programming too.

You're project sounds interesting too. And it will do that from an airplane,right?

benedict's post on the last page now has me thinking about using this collect the data to a PC, I started out just thinking in terms of displaying it so I could read and take notes...

As it is now I think my direction with this thrust measuring during static testing might be to get it into a PC on a serial port and have in collected directly into a Excel spreadsheet that can list and/or graph the data.

I get all the other data I want now from the Eagle Tree eLogger and add the thrust data later from notes taken during testing. I don't want to replace the eLogger because it can also be flown and do a lot of other things too (with various accessories) in flight.

But this is really complicated and new stuff to me so I am struggling a little as you can tell.

But there is a lot of room for Arduino in this hobby, that is for sure.

Jack
Apr 05, 2014, 03:46 PM
Jack
jackerbes's Avatar
Thread OP
Here are a couple of the things I have stumbled into that look to have the potential to be part of this process.

One of the tools described here, PLX-ADQ is the terminal that will be part of the process I think

And here is an example of the process for getting data into Excel (via PLX-ADQ or another similar means) and it gives you an idea as to what can be done with the data:

http://robottini.altervista.org/ardu...36505126953125

I am getting a little ahead of myself here, I have to get that beam sensor figured out and reading accurately first...

Jack
Apr 06, 2014, 08:28 PM
Registered User
benedict's Avatar
Please do keep us posted. This is a great thread.

Two other ideas for spreadsheetisms:

A while back I got an SD card board from DFRobot. The API gives you commands for opening text files, sticking stuff in the text files, and closing them. Perfect for logging. printf() commands can be used, so you get complete control over the format. Great for making CSV files that can be read directly into Excel.

Another idea: A while back I got an ATTiny USB Key from Sparkfun. This is basically a printed circuit board with the ATTiny chip on it, and four traces at one end that let you plug it into the USB slot on a computer. The stock code on the ATTiny emulates a keyboard on the USB port, and once a second "types" the value from one of the A/D ports on the chip, followed by a carriage return. The code is pretty straightforward to read and modify. I know this takes it outside the realm of the Arduino, but it's a possibility. The neat thing with this setup is that you can open Excel, plug this thing in, and it types data directly into it. One of the funkiest data loggers I'd ever seen, but it works remarkably well.

I'd love to see an Arduino Micro with a microSD slot on it. That would make a great data logger, and would fit in a plane alongside the Eagle Tree you've got. You could track temp, current, voltage, RPM, all kinds of fun stuff.

Come to think of it, I could've used a flight data recorder a couple of times. You know, those flights where you watch your plane do something weird, followed by a loud crunch? It'd be nice to have a little box (say yellow or black?) you could plug in that would log everything.

Cripes... There I go providing feature creep for someone else's project. Must... Stop... (I have enough projects of my own right now. )

Keep plugging away at it!

Tom
Apr 07, 2014, 06:40 AM
Jack
jackerbes's Avatar
Thread OP
Quote:
Originally Posted by benedict
Please do keep us posted. This is a great thread.

Two other ideas for spreadsheetisms:

A while back I got an SD card board from DFRobot. The API gives you commands for opening text files, sticking stuff in the text files, and closing them. Perfect for logging. printf() commands can be used, so you get complete control over the format. Great for making CSV files that can be read directly into Excel.

Another idea: A while back I got an ATTiny USB Key from Sparkfun. This is basically a printed circuit board with the ATTiny chip on it, and four traces at one end that let you plug it into the USB slot on a computer. The stock code on the ATTiny emulates a keyboard on the USB port, and once a second "types" the value from one of the A/D ports on the chip, followed by a carriage return. The code is pretty straightforward to read and modify. I know this takes it outside the realm of the Arduino, but it's a possibility. The neat thing with this setup is that you can open Excel, plug this thing in, and it types data directly into it. One of the funkiest data loggers I'd ever seen, but it works remarkably well.

I'd love to see an Arduino Micro with a microSD slot on it. That would make a great data logger, and would fit in a plane alongside the Eagle Tree you've got. You could track temp, current, voltage, RPM, all kinds of fun stuff.
If you haven't looked at it before, the eLogger is hard to beat for logging data as it is now. It is small and light and simply added between battery and ESC on any plane. And that will give you all the V/A/W/CumAh info. Add short leads and small DIY temp sensors and you can get two temperatures, add one short wire with a pin and the small brushless RPM sensor, and you can have RPM.

The eLogger comes with a decent data plotting and diplay app for the PC and the data is Excel ready CSV data if you want to do more with it in a spreadsheet. There is a brief explanation of the data stream in the user's manual.

Quote:
Come to think of it, I could've used a flight data recorder a couple of times. You know, those flights where you watch your plane do something weird, followed by a loud crunch? It'd be nice to have a little box (say yellow or black?) you could plug in that would log everything.

Cripes... There I go providing feature creep for someone else's project. Must... Stop... (I have enough projects of my own right now. )

Keep plugging away at it!

Tom
We'll continue to mess with it for now for sure. Yesterday I stumbled across a download at github that has a more feature laden implementation on the use of the Hx711 board:

https://github.com/bogde/HX711

I'd like to find the build that the guy that the guy did using that code...

Jack
Apr 07, 2014, 08:03 PM
Jack
jackerbes's Avatar
Thread OP
Starting to close in on something here!

I played with the sketch from that last link I posted and have this working now. I also did a little tweaking on the hardware as far as how the beam is mounted.

But with the software loaded, you can see the readings in the image. It sets idle with a slightly minus reading and then as I added my various weights it steadily comes up. The total weight figure of 2539 is about 15g more than the same weights on another scale I have. So it is very close to right. Close enough for this for sure.

The software I have now is both taking spot readings and then averaging 20 readings and that slows things down some. I'm now going to look at grooming the software down a little to do less and respond quicker. So I'll do a little testing to see if it will hurt the accuracy to go for a little quicker reaction.

Jack
Apr 08, 2014, 05:39 AM
Don L.
Jack, you might try removing the delay at the end of the loop to speed things up.

-Don
Apr 08, 2014, 06:53 AM
Jack
jackerbes's Avatar
Thread OP
Quote:
Originally Posted by dleroi
Jack, you might try removing the delay at the end of the loop to speed things up.

-Don
Thanks for the suggestion, I had suspected that would help. The *.ino file I am using now it attached in a text file. I think the things I want to do to that are:

1 - Disable the testing and calibration at the start and see what that does to the readings.

2 - Disable the averaging the readings and see it just sending reading taken at intervals creates a problem with inconsistent readings

3 - Play with the interval and baud rate to speed things up.

4 - Get the LCD shield working (it is not on the UNO board right now).

5 - Add a Tare function to one of the buttons on the LCD Keyboard shield I am using.

As you know, it is slow for me because I read a statement and then have to go off and study it to see if I can figure out what it is doing. The Arduino Cookbook is helping some but it is slow for me...

As I'm sure you know, I am still a Neanderthal at all this and any stabs you want to take at it are welcome.

When I was in the Navy I brushed shoulders with some programming and programmers. And I clearly remember that there were folks that could write code and folks that could copy, edit, and fine tune code. And I am one of those latter types.

Jack
Apr 08, 2014, 02:41 PM
Jack
jackerbes's Avatar
Thread OP
Today I edited the daylights out of the Arduino sketch file I had been using. I have it down now to where it is only printing one heading and then the weight values without any averaging.

I have played with the timing of the loop, having had it down from 5000 (5 seconds) to as little at 50 (50 milliseconds) and it runs fine at the higher speeds. I have set it back up to 5000 for now just to slow down the process as I play with it.

I think now I will try to get the same thing on the LCD display.

Moved the hardware around a little again, think it is set up now to where I can soon use it on the stand and read values from the LCD (when I get the LCD working).

So now we are off to study LCD stuff...

Jack
Apr 08, 2014, 02:52 PM
Registered User
benedict's Avatar
Ok, you're right. The eLogger is sexy. (Dang it, one more thing to save up for!)

I don't know how the Arduino reads the ADCs on the AVR chip. I'm relatively new to Arduino coding, though I used to do AVR development once upon a time. There are some neat tricks you can pull when setting up the ADC ports that will help clean up a noisy signal at the expense of readout speed. One is to set the port to oversample and average internally before reporting a value back.

Given that you're seeing slow performance averaging just 20 readings, I'm guessing the Arduino's API has the port set to average a ton of readings before returning one. I like your item #2. If the noise is low enough that you don't need to average, skip it and move faster.

There was an Atmel white paper on how to get more bits out of your ADC that was pretty cool. You basically oversample like nuts, and rather than averaging you add. Treat that larger number as your value. If you take 16 samples this way, you can essentially treat your 10-bit ADC as a 12-bit ADC. (Yeah, I know 16 samples should give you 4 bits. But there really is a lot of noise in there, so you kind of have to drop the last couple of bits anyway.) This trick really works best with a noisy signal. If you just have a series of consistent values from a low-noise sensor, it doesn't buy you much.

Something you might also code in in addition to the tare button is a calibration button. A scale we have at work came with a 100g weight. You turn on the scale, tare it out, put on the weight, hit Cal, and now you know between 0 and 100g it's pretty good. Something similar using a 1kg or 2kg weight would work well for your application.

Glad to see you're homing in on code that'll give you what you need!

Tom
Apr 08, 2014, 07:56 PM
Jack
jackerbes's Avatar
Thread OP
Sounds like you're a lot smarter than I am on a lot of this... Stick around!

I think the Arduino sketch I started with was for the needs of the guy that wrote it and he had it serial only and 5 second delay between sending values. And that may have met his needs.

I think on the LCD I would like a single display of four digits (5000g is the sensor's rating) and just have that value refreshed at a rate the does not make it hard to read the last two digits. I have a 2 x 20 display and need to go off and study that too. If the LCD can turn the two lines into double height digits that would do me fine. And, for the long term plan (I'm not working on that end yet) it can be sending the values to a capture file on the PC via a serial port if I want to have them there.

And the AC adapter on my laptop just died! So where I've doing most of the research and stuff up in the warm cozy living room I am now down in the still a little chilly basement until I get a new AC adapter for my laptop (it is on it's way via an eBay purchase). Working in a chilly basement really stifles my desire to mess with things...

Jack
Apr 08, 2014, 09:31 PM
Registered User
Hi again Jack,

There is a way to turn off all clocks (put the Uno's controller to sleep) except for the ADC clock just before the ADC takes a sample. Do you know if your sketch (program) uses the ADC interrupt to read the sample when the conversion is complete or if it sits there and polls the ADC status register to determine when the conversion is complete?

I have sample code bookmarked on another computer and will get it to you in the AM.

I sympathize with you on the basement temperature. Mine is 52 deg F in the middle of winter and is slowly reaching 58 deg F as outside temperatures rise. It is hard to do much work for any length of time.

Alan
Apr 09, 2014, 06:01 AM
Jack
jackerbes's Avatar
Thread OP
As far as I know the clock on my HX711 board is not turned off. It is such a small and simple board that I might be surprised that it has one. But then, I know so little...

Looking forward to the code and appreciate it.

Beautiful day today, 40F at 0630 and clear blue skies, we'll get to 60 probably. This is one of the best times of year for me and for flying with dead still air in the early hours. And the black flies and tourists are not here in any great numbers yet.

This morning I'm going to mess with the LCD, load some sample code and see what that looks like and then I'll eventually work on getting the LCD code interspersed into the weighing code.

Jack


Quick Reply
Message:

Thread Tools