NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Support Forum » WeighScale Project - Python Code
November 03, 2010 by bdubb427 |
Hi, I have no experience with using python, so I am just trying to run the source code given for the weighscale project. After opening the pc-weighscale.py file in Python ver 2.6, I am getting an error that says "ImportError: No module named serial" (line 1) I'm assuming this is a problem with the header files. Can someone please help so I can get the source code running? |
---|---|
November 03, 2010 by bdubb427 |
I don't understand what to do about the list of modules im supposed to import. They aren't included so am I supposed to write them myself? I don't know where to start or what to do... |
November 03, 2010 by hevans (NerdKits Staff) |
HI bdubb427, PySerial is a module that is not part of the core python modules, so it must be installed separately. Just grab the right version from the PySerial Website, install it and you should be good to go. Let us know if you run into any problems. Humberto |
November 04, 2010 by bdubb427 |
Hey Humberto, Thanks for the help. I seemed to follow the steps on the Pyserial Website, and using the pyserial-2.5.win32.exe file, it seemed to install without any problems. I then again went back python, uploaded the same source code and tried running the module again, but this time it's giving me an error with the "import wx" module. If I comment out that module, I get an error with the "import wx.lib.plot as plot" command. If I comment out that module, I get an error with the "s=serial.Serial" command, and several other errors. Can you please recommend to me where I can download other modules for this source code? And anything else I might need to download and install seperately to get this source code running. Thanks alot! -Bryan |
November 04, 2010 by hevans (NerdKits Staff) |
Ah, sorry about that. We also used a graphics library called WxPython to do the GUI side on that project. I actually suggest you download the other version of that script (pc-pygame.py). That one uses PyGame (which you also need to download separately) to do its GUI, and its a little easier to install, and more useful once you have it. Here are the links to WxPython and PyGame websites. Humberto |
November 04, 2010 by bdubb427 |
Hey Humberto, sorry for all this trouble, but I STILL can't seem to get it running without any errors. After installing WxPython successfully, and also running the demo successfully. I reloaded the pc-weighscale.py file onto my Python GUI and clicked "Run Module" again. But I am still getting the error "import wx.lib.plot as plot" Also, I would LOVE to download the run the other version of the script (pc-pygame.py) using PyGame, but that website seems to not be working at all! I don't know if the server is down or not, but pygame.org seems to not be responding :-( I really appreciate all the help! Thanks! -Bryan |
November 04, 2010 by hevans (NerdKits Staff) |
It looks like you need to install the NumPy module. I checked just now and the PyGame website is back up. Humberto |
November 09, 2010 by bdubb427 |
Hey Humberto, running into more poblems weighscale.py program. I installed the NumPy module and went back to running the program. ◦ So there's a li the code that says s=serial.Serial("/dev/ttyUSB0", 115200) I changed "/dev/ttyUSB0"</bold> to COM5, just like in the tutorial. Besides that, I made no changes to the source code. |
November 09, 2010 by bdubb427 |
Also, since the pygame website was back up and running, I decided to try running the PC-Pygame.py code. The pygame version available on the website (pygame-1.9.1) only works with Python version 2.4. I had to install Python2.4 and then install pygame. After running the code, the "serial" error came up again just like the pc-weighscale.py code. I tried installing PySerial (pyserial-2.5.win32.exe) and the error still appears. ◦ There is another error that says "no module named ctypes". I read that python 2.4 does not include these ctype modules that are necessary to run with pygame. Please help!!! |
November 10, 2010 by hevans (NerdKits Staff) |
Hi bdubb427, On the PyGame downloads website under Windows the 4th link from the top is pygame-1.9.1.win32-py2.6.msi, which is PyGame for Python 2.6. I would uninstall Python 2.4 and go with 2.6, it is at least for now the most widely supported. As for your serial error above, make absolutely sure your COM port is the same as the one in the Device Manager, and make sure you don't have anything else that is currently using the programming cable (not currently programming the chip, or have a Putty session open). Humberto |
November 16, 2010 by bdubb427 |
Up and running python 2.6 and installed pyserial to 2.6. The serial error in the pygame code is gone!, and the "Pygame window" pops up with I run the code (with nothing in the window), but I am still receiving a couple of errors with the Pygame code. Plz help Humberto! Explain these two errors to me please. |
November 16, 2010 by bdubb427 |
Humberto, as for the serial problems I am having with the weighscale code as posted in the picture above, I double checked the device manager and it is certainly the COM5 port that i'm using. Also, I made sure no other ports were being used, and nothing else was using the programming cable. Are there any other solutions to this problem? |
November 16, 2010 by bdubb427 |
This is the new screenshot of errors I get with the weighscale.py code. Now that i'm using Python 2.6 instead of 2.4, the ctype error I get is gone, but the serial errors are still there. |
November 16, 2010 by hevans (NerdKits Staff) |
Hi bdubb427, On the cannot open background error you need to either change the background to a different picture or just comment out that line entirely (add a # at the beginning of the line), we had a picture in the background for demo purposes. It should fix that issue. The access denied error is a bit harder. Are you positive that nothing else is using the serial port? No hyperterminal or putty sessions open? Did you perhaps try to open it form a a python session earlier that caused another error, and now that python shell still has control of the port? Is it possible that you don't have administrator privileges on that machine to open the serial port? Let me know if you are still getting that error. There are a few things we could try. Humberto |
November 16, 2010 by bdubb427 |
Ok for the pygame code, I commented out the background line entirely (line 120). After running the module again, I got another error, this time it was another background error "screen.blit(background, (0,0))"(line 131). I also decided to comment that code out (not sure if that will change anything). After commenting out those two lines, I re-ran the module and this is the window that pops up Just a blank black screen with a blue line. When I close the pygame window, this is what appears on the shell window with a bunch of new errors. As for the weighscale code. I am positive nothing is using the serial port. I only have the USB cable plugged into my laptop(COM5). I tried closing all the python sessions, and even restarted my computer and I still get the same error. And I do have administrator privileges on this computer. Is there something I need to do to open the serial port besides change the name in the code to COM5? |
November 16, 2010 by hevans (NerdKits Staff) |
Hi bdubb427, In the pc-pygame code go and uncomment line 117, which will fill in white as the background color and make things easier to see. While it is running, are you getting any errors on the Python Shell? I'm not surprised you get errors when it closes because of all the running threads that suddenly exit, but if you are not getting any errors while it is running it means it is working. The blue line will move once it starts getting data from the serial port. Just out of curiosity have you tried running Putty to see the data that would be coming in over the serial port? Just to make sure that side of the whole system is working correctly. Humberto |
November 16, 2010 by bdubb427 |
Hey Humberto, i commented out line 117, but the pygame window still appears black with the blue line. (No white background!) No, while it is running, i do not get any errors in the python shell. The blue line doesn't seem to be responding to my weight scale unfortunately. I am unfamiliar to Putty and how to use it with this project. Please explain! |
November 17, 2010 by hevans (NerdKits Staff) |
Hi bdubb427, I meant remove the # mark so that the line is not a comment. That way it tries to fill the background with white. Likes 117, 118 should look like this
Hopefully that will get while on the background of your PyGame window. To use Putty to view the incoming data go to the Servo Squirter video and scroll down to the serial communications section. Follow the instructions to use Putty. Putty when configured this way is just acting a serial teminal so it will display anything it receives (and send anything you type). Humberto |
November 29, 2010 by bdubb427 |
Hey Humberto, After removing the comment symbol from that specific line 117, so my code looks like this: This is the current error I get: Instead of getting a black background screen with a blue line like before, this time the Pygamewindow pops up, but is "Not Responding" with no image and I have to end up closing it do to it's unresponsiveness. Also, I have my HyperTerminal screen up using the directions on the Servo Squirter page, along with the correct settings as it asks for on the screenshots, (COM5, and changing the port settings to match the screenshot) but nothing appears in the HyperTerminal screen. Oh and since we are playing around with the comment symbols, I decided to take the comment symbol off of line 116 "background = py.gameSurface(self.size).convert_alpha()" and the black screen with a blue line appears again. Either way I'm getting a pygame window with black screen with a blue line, or a non responding pygame window. Please help. |
November 29, 2010 by bdubb427 |
oh BTW, is the board for the weighscale project supposed to have a battery source like the TempSensor project? Cause in the weighscale video the tutorial, the board shown in the video is missing the battery source and the voltage regulator... so i removed both |
November 30, 2010 by bdubb427 |
Ignore my last comment. I realized that the USB programming cable provides power through the red/black wires. I had to move it to the red/blue rail on the side of the breadboard. |
November 30, 2010 by hevans (NerdKits Staff) |
Hi bdubb427, Lets stick with Hyperterminal for now to make sure you are getting data out of of your weigh scale over the serial port. Don't try to open the python code and the the HyperTerm on at the same time since only program can have the device open at one time. Do you get anything at all coming over the serial port? If you are not seeing anything at all it tells me your chip isn't even turning on. My suggestion is to put a line in that blinks an LED on and off in your code to make sure the code is at least running, and we can start debugging from there. Humberto |
November 30, 2010 by bdubb427 |
Ok so I have only HyperTerm up and running (with the properties matching in the screenshots), but nothing is appearing on the screen. In fact, the bottom left hand side of the window says "Disconnected", which probably means it's not even reading the cable at all. I have no idea why it's not working, because before I attempted this weighscale project, I had completed the Temperature Sensor project and it worked PERFECTLY. But I will go ahead and follow Nerdkits Tutorial to "Blink an LED" to see if that works. |
December 01, 2010 by exussum |
Press the little phone icon at the top ? Is it still on COM5, Sometimes it can change. Check though Device manager. |
December 01, 2010 by bdubb427 |
Ok so HyperTerm doesn't seem to be responding to anything. Here's the steps I have taken so far for debugging: Following the "blink an LED" tutorial, i used WinAVR to and the given code to actually get my LED to blink. It DID work, my LED blinks, so there's nothing wrong with any connections or the programming cable. After the Blinking LED tutorial, I tried opening up hyperterminal again to see if there was any response in the screen, and once again, nothing. Exussum, I even clicked the little phone icon at the top, but it doesn't do anything. And i've checked Device Manager everytime and it's still on COM5. I did not attempt to write any code in Python yet. Should I go ahead and proceed with that? |
December 01, 2010 by bdubb427 |
Here's what I notice. I'm pretty sure that the code from Python is not even programming into the MCU properly. When I switch the programming header "down" to run the last program that was saved on the chip, the LED blinks, which tells me that nothing new is being written to the MCU. What should I do now? |
December 01, 2010 by exussum |
Open your Makefile in a text editor. Post the first 4 lines, The project from the 4 blinking lights will be fine. Could you also post a screenshot of the settings your using for hyperterminal. |
December 01, 2010 by bdubb427 |
Here is the screenshot of my hyperterm settings: And which makefile are you referring to? The one for weighscale.c? Does that have anything to do with pygame or weighscale.py? Well, here's a screenshot of my WeighScale.C makefile... I actually tried using someone else's code to display the "active" weight on the LCD with the weighscale.c program, but he couldn't seem to get an active reading of the weight on display either. Here is his post and code Am I supposed to run the weighscale.c first then run the python files? Well, my experience using python has been nothing but a fail recently.. |
December 02, 2010 by hevans (NerdKits Staff) |
Hi bdubb427, Lets try to leave python out of the equation entirely for now, and make sure you have a weigh scale program that can send programs out the serial port to the MCU. The weighscale program just spits out its readings of the ADC over the serial port, so if you load up the weighscale.c program and then run it you should just see numbers coming across on hyperterminal. Disconnect your scale, and everything else that might be causing an issue when you try this, and let us know what you get. Also, post some pictures of your setup, it is possible something is just causing a short causing your MCU to shut down,and that is why you are not seeing anything. Do you get any sort of error message when you are attempting to load the weighscale.c file onto your chip? Humberto |
December 02, 2010 by bdubb427 |
The following are a couple screenshots of my setup, sorry if it's a little blurry, I only have my iphone camera at the moment and it's not the best quality. Currently I am running power through the 9v battery instead of the power from the USB cable. The capacitors are placed in series to equal 10 uF, and the resistor adjusted for gain is about 333 ohms. I have disconnected the weighscale like you said. The LED is just there to see if the LED blinking program would work, and it did. And the temp sensor program works as well. Even running those programs I see no response from HyperTerm. The second image of the LCD with a bunch of blank characters shows me that something is being written to the MCU if I am not mistaken. Here is the output I get when I run the weighscale.c code in WinAVR And this is my Hyperterm screen with the appropriate settings. It would be nice to get an active reading of the weight on my LCD, since python doesn't seem to be working for me for now... Bryan |
December 02, 2010 by exussum |
Is your chip still in program mode ? can you adjust the contrast of the screen at all ? Play around with the resistor - I cant acutually see it on there, Mine is a little blue component with 3 legs. your second to last screen shot shows that communication is happening BOTH ways from the chip. |
December 02, 2010 by bdubb427 |
The screenshot of the LCD is displaying AFTER the weighscale.c program is loaded onto the chip I believe. And what do you mean by adjust the contrast of the screen? And which resistor? I don't have any resistors on here that have 3 legs. |
December 02, 2010 by bdubb427 |
What kind of output am I supposed to get from the weighscale.c code that proves my program is working? There is no LCD output display or anything... can I possibly get some help to display an active reading of the strain gauge on the LCD? |
December 02, 2010 by exussum |
Just read it Add above while(1){ Should display Working on your Screen then |
December 02, 2010 by bdubb427 |
I actually did that earlier, and the LCD can display my string message of "Working", but I guess my question was how do I get a reading from the strain gauge on the LCD? |
December 02, 2010 by exussum |
fprintf_P(&lcd_stream, PSTR("label: %.2f"), adc_read()); That will show the number to 2 dec place |
December 02, 2010 by hevans (NerdKits Staff) |
Hi bdubb427, The fact that you don't get anything on Hyperterminal from the tempsensor program means something isn't right on the PC end. I'm concerned that it still says "Disconnected" on the lower left hand corner. It should say connected once it connects to the serial port. Did you try clicking the little call button after you setup the connection? The other thing you can try is using Putty to the terminal emulation. In my experience it is friendlier to use. Humberto |
December 02, 2010 by bdubb427 |
Exxsum, I have tried to print that display to read from the ADC, but I am getting no change in value when I apply a weight to the strain gauge. Humberto, Even after applying the correct properties to HyperTerm, it says "disconnected". I click the phone icon and all it does is ask me to make a new connection. I will download putty and attempt to use it. Can you show me what I am supposed to do after I download Putty and install it? |
December 02, 2010 by hevans (NerdKits Staff) |
There is a section on the Servo Squirter page right below the Hyperterminal instructions on how to setup Putty. You basically just double click the icon, set the connection type to Serial. Set the COM port and baud rate and click open. Humberto |
December 02, 2010 by exussum |
But it is showing an initial value ? after putty is installed click serial on the main page - Change to COM5 and 115200 and click open, it shows a black screen ready you input / output |
December 02, 2010 by bdubb427 |
Ok, Putty is up and working. HEre's what I get when the weighscale.c program is running It's constantly scrolling down.. so I assume that something is working Exussum, I am getting a initial value of 0.00. But not a reading that changes with the strain gauge :-( |
December 02, 2010 by exussum |
Ahh i see, I mentioned before to put some of the code above the while loop. That was because it should be repeated You want the code to update the LCD to be repeated. You will need to change some code. Change ...
to
See if that updates the screen |
December 02, 2010 by bdubb427 |
Exussum, I did that and what's happening is this: el: 757label: 757lab for all four lines of the LCD while continuously scrolling down (just like in Putty) I added the line of code: lcd_line_two(); beneath the line: fprintf_P(&lcd_stream, PSTR("label: %d"), reading); and my new display only has two lines of display on the lcd now: label:758 label:759 |
December 02, 2010 by exussum |
Ahh I forgot another line sorry. You will need to run LCD_home(); once in each while loop before you print to LCD. Trying on iPod touch so syntax will be slightly wrong |
December 07, 2010 by bdubb427 |
Ok guys, well whatever is showing up on PUTTY is now displaying on my LCD screen. (About 745 WITH the amplifier connected, and some random lower numbers without the amplifier connected) I guess my question for now is, where is this value coming from, since it's not actually coming from my weighscale. The next step is, how do I get a reading from my weighscale??? I'm going to upload pics to show my weighscale setup.. I had a couple questions about that as well (such as which is S+, S-, E+, E- (cause it's not labeled!) |
December 07, 2010 by bdubb427 |
Bought Health O Meter weighscale from walgreens. The inside with a single wheatstone bridge setup. The 4 (sense/excite) wires are on the back of the LCD display. Here is the 4 wires, (light blue, yellow, black, red) I know the camera quality is pretty bad, so I tried my best to label what the board says. Above the 4 wires it says (C7, C8, R25), Beneath the four wires says: L, Y, B, R (for the colors I'm assuming, but not quite sure what color L is except light blue??) and on the right of the four wires it says SENSOR. I labeled them on the picture. Any other colored wires are just the wires that I soldered onto the board to connect to my MCU/Amplifier |
December 08, 2010 by exussum |
What wire do you have plugged in ? Upload a picture of your board, With as much extra detail as possible (eg Standard nerdkits set up, and pin 17 is from my mV source) |
December 08, 2010 by bdubb427 |
Right now, I do not have any of the 4 wires plugged in. Only because I am unsure which wires are Sense and Excite. Im going to have to assume the black and red ones in my weighscale are the "EXCITE" just like the one's in the weighscale video tutorial, but I am unsure of this. The setup of my board is EXACTLY like the setup of the board in the nerdkits tutorial (and the weighscale video), the only difference is that I'm using the power from the 9v battery instead of the USB, and I have the LCD connected. If you still need a picture, I will try taking one with a better camera as soon as possible. |
December 08, 2010 by exussum |
from your pictures above - you still have the temp sensor in ? The values will be coming from that. Unless i misunderstood |
December 08, 2010 by bdubb427 |
Ok sorry, I forgot to mention, the temp sensor has been removed. So currently, the values still appear WITHOUT the temp sensor in. Any other explanation? |
December 08, 2010 by exussum |
im no expert but I THINK thats normal. Im not sure if any of this is correct, so i hope someone can correct it later, All of the time, and all around you there are radio waves, TV waves etc - Which are really useful, but at the same time can cause external noise to effect the readings you are taking. The wire running up the breadboard acts as an antenna taking in all of these signals - which could create a few mV. All antennas will receive thousands of signals at one time, which is what could be happening here. Have your phone close by and make a call, On a speaker system it has an effect of making that weird noise come out of it, On your nerdkits it could make the numbers vary a bit more. By amplifying it you are just amplifying a large range spectrum no nothing will stand out or sound like the radio you usually listen to. http://en.wikipedia.org/wiki/Radio_frequency Further reading there, to vary the formula for different frequency's the capacitance should be varied. There is some noise reduction techniques on the video for this project, the one i remember most was the switching of polarity, effectively dropping out the noise (Assuming the noise stays constant though 2 reads) |
December 08, 2010 by bdubb427 |
Hmm, well. I tried making several different phonecalls around the breadboard and it didn't affect the numbers at all. I feel like it's just a random string of numbers appearing on the lcd, i do notice tho, that the values SLIGHTLY change when using power from the 9v battery, than using the power from the USB cable, so maybe the reading is of the voltage coming from the battery??? Anyhow, I still am stuck with being able to get a reading from the WEIGHT SCALE that i bought. How do I get an active reading through the sense and excite wires? I've tried plugging the wires i soldered onto the weighscale into the MCU Pins, just like the tutorial says (MCU PD3, MCU PD4, and the amplifier pins, 2 and 3, and having the output of the amplifier (pin 6) go into MCU PC0, but the result is still the same. It's just some random number that has been amplified and does not change due to the weighscale at all! |
December 08, 2010 by hevans (NerdKits Staff) |
Hi bdubb427, exussum is correct with nothing at all connected to your ADC there is nothing that is driving it so it is pretty much anyones guess what its value is. Do you have a multimeter around? Have you tried measuring the voltage coming out of your Wheatstone bridge (after amplification)? Try driving the excite wires directly, amplify the difference on the sense wires and measure that directly, do the numbers you get make sense? Humberto |
December 08, 2010 by bdubb427 |
Sorry Humberto, I currently do not have a multimeter laying around, but I will borrow one from a friend when I see him later today. So I just want to make this clear before I go get the multimeter later. So what I should do is drive a voltage into my excite wires (assuming its the black and red wire) and have the sense wires (light blue and yellow) go into amplifier. Then measure the output on the amplifier with a multimeter? I currently have time before I get my hands on the multimeter, so I took the time to draw a schematic. Sorry I am very new at this and I just want to make sure I am doing everything correctly! So in theory (if all goes according to plan), that after testing this out, and the values DO make sense... The weighscale code that I have (to show an output on an LCD) should display the correct weighscale if these wires are plugged into the correct MCU/AMPLIFIER pins? |
December 08, 2010 by bdubb427 |
Ok so a new question arises. I realize that the AD620 in the given schematic is not the same configuration as the AD620 that I bought. Here is the IN-AMP that I bought. My question is, the original schematic shown in my previous post has +5V going into Pin 7, and +5V & 10K resistors & 10uF Capacitor going into Pin 5. Does that mean Pin 7 is Vs+ and Pin 5 is Vs- ? Or vice versa? I plugged the +5V into my Vs+ pin, and left the Vs- pin for the other 5v input with the resistors and capacitors. But I got NO amplification from that. When I tried switching it around and put the 5v input with resistors and capacitor in the Vs+ pin, the INAMP got extremely hot so i unplugged it right away. Can someone help me with the proper setup???? |
December 08, 2010 by bdubb427 |
Sorry ignore my last comment. Following the configuration for that AD620BNZ that i posted in the previous comment produced no amplification. Now if i follow the original nerdkits schematic, I got an amplification of nearly 2x. I drove a voltage of 1V into the input of the amplifier, and recorded an output of 2.12Volts. The INAMP is working!! Now I need to connect my weighscale to it and get it to display on the lcd! |
December 08, 2010 by bdubb427 |
New update. changing my 333ohm resistor to 2.5k ohms produces NO change in amplified output! In fact, when i take out the 333 ohm resistor completely from the in-amp, the resulted output is STILL the same! It's still 2.12 volt even though i am driving 1.0v into the input!! Why??? |
December 08, 2010 by bretm |
How exactly are you driving 1V into the input? I don't think it would work to put 0V at minus and 1V at plus because the specs for this inamp say you should stay 1.6V away from the rails. So if you put 2V at minus and 3V at plus, the output should be the reference voltage (2.5V) plus 1V times the gain, but the output also can't reach the rails, so it would be close to clamping even with G=1. I'd start with a 0V differential input, and then go to 0.1V and see if it's amplified. |
December 08, 2010 by bdubb427 |
Hey Bretm, I'm kind of unsure what you are asking me to do. Yes, currently I am driving 1v into the (input+), and 0v into the (input-), I also assumed that this voltage may be too big as an input, so instead I tried putting 5mV into the (input+), and 0v into the (input-) but the result is still the same. I realize the 2.12V reading is coming from the 5v rail from the USB cord. When I unplug the 5v from the USB cable (which also runs through pin 6 and 7 of the inamp), I get a result of 1.4Volts.. but once again I think this result has nothing to do with the inamp, because changing the Gain resistor (333 ohms) does not affect the result AT ALL. |
December 08, 2010 by bdubb427 |
having a ZERO difference for Input+ and Input- has not changed my result either :-( I dont know what is wrong with my setup. |
December 11, 2010 by mrobbins (NerdKits Staff) |
Hi bdubb427, When the AD620 is being powered "single-sided" from 0V and +5V supplies, the input range is very roughly +1.5 to +4.0 volts relative to ground (reading from Figure 21 in the AD620 datasheet). The output range is very roughly +0.7 to +4.0 volts relative to ground. You have to make sure that both of your inputs (+ and -) are both within this +1.5 to +4.0 volt range. A simple test might be to connect Input- to the 2.5V reference (the REF pin), and then to connect Input+ to the center tap of a potentiometer that has its other two pins between 0 and +5V. Observe the output voltage as you sweep the potentiometer near the middle of the range. Remember that with a gain of 150 or so, your entire output range of about 3 volts will be covered by a 20mV change in the input differential voltage! Mike |
December 11, 2010 by bdubb427 |
Hey mike, thanks for the help. Yes, I came to the conclusion with the friendly help on these forums that my input range had to be within 1.5 to 4.0v when having 0V and +5V supplies. My question is does the input from the digital strain gauge fall inbetween that range of 1.5 to 4.0v? I tried plugging in my strain gauge's "sense" wires (at least i think they are the sense wires) to see if my output would change due to applying a weight on the scale, but unfortunately I saw no change in output. I will continue to try to debug this problem but please let me know if all I am supposed to do now is just connect the "sense+/-" wires in the inamp and "excite+/-" wires in the mcu... and measure the output... |
December 11, 2010 by mrobbins (NerdKits Staff) |
Hi bdubb427, When you connect the "excite" wires to +5.0V and 0V, the two sense wires should both read around +2.5V relative to ground. (The bridge is generally built with balanced resistance values.) When you apply a force, one of the sense voltages should increase a little bit, and the other will probably decrease by roughly the same amount. However, the amount of change we're talking about is tiny -- perhaps a millivolt or less -- so it may not be something you would see on a multimeter. That's what the amplifier is for! Can you confirm that when you connect the excite +/- wires to 5V and ground respectively, that both of the sense wires measure about +2.5V to ground? Mike |
February 17, 2011 by bdubb427 |
I'm reviving this thread after taking a long break in not working with this project. So please bare with me. Mike, instead of using a digital weight scale in previous posts, which seemed to give me more trouble than what it's worth, I went on ahead and bought a load sensor. As shown here http://www.sparkfun.com/products/10245. This website even refers to the nerdkits tutorial on how to use the load sensor! Each one of these load sensors is half a wheatstone bridge, so I went on and bought two of them, connected them together to complete a full wheatstone bridge. I can now confirm that when I connect the EXCITE wires to 5V and ground respectively, that both the sense wires DO measure about +2.5V to ground! Applying pressure on one load sensor will decrease the voltage slightly, and the other load sensor will increase the voltage slightly. (As expected) Here comes the part where I am stuck. I am still a beginner with writing C programming, but using the weighscale.c program, and adjusting the code so I can display an "active" reading of the load sensors, I am getting a ridiculously large number. I want to know if someone can help me convert this number so I can get a weight reading in pounds.
So with this code, I am getting my LCD to display "label: 525", and constantly looping, so when I apply pressure to the load sensors, it increases or decreases that number. Can someone direct me in how to convert this random number/value into a realistic weight? |
February 17, 2011 by Ralphxyz |
Does the number vary by weight? What are you doing to get these numbers? If you weigh a 5# object what number do you get ? Then weigh a 10# object? and a hundred# object. You should be able to understand the number if it varies by weight. Ralph |
Please log in to post a reply.
Did you know that you can control multiple LEDs from one microcontroller output? Learn more...
|