A few weird programming issues!
Gaby D.
Posts: 8
Edit: Another programming issued detailed in a below post. thanks!
What I need this thing to do is increase the set temperature by one every time I press this button...
But, what it does instead, is stay stuck on 1 FOREVER, and still increase the set temperature.
I can only get the IN9=0 if I.. stick my hand near the wires inside of the box.
If I move my hand outside of (what I assume to be) the electromagnetic field, it reverts back to 1 again. My project partner didn't believe me until he experienced it himself!
So, recap:
I press the button which gets IN9 = 1, the setTemp goes up constantly because it stays, and the only way to get IN9=0 is if I disrupt whatever the heck is going on with my hand, which doesn't have to include physical touching of any wires or components.
Is there any way I can
1) Get the set temperature to go up by only one, for every time the state is at 1 (in other words, every time IN9=1 it goes up by only 1)?
2) Minimize this field (or whatever on earth is causing the problem)
heres the snippet of messy test code we have so far:
setTemp VAR Word
setTemp= 60
DO
IF(IN9=1)THEN
setTemp=setTemp+1
PAUSE 100
ENDIF
PAUSE 100
DEBUG CRSRXY, 6, 3, DEC setTemp, TAB, DEC IN9, CR
LOOP
Post Edited (Gaby D.) : 11/9/2009 9:16:26 AM GMT
What I need this thing to do is increase the set temperature by one every time I press this button...
But, what it does instead, is stay stuck on 1 FOREVER, and still increase the set temperature.
I can only get the IN9=0 if I.. stick my hand near the wires inside of the box.
If I move my hand outside of (what I assume to be) the electromagnetic field, it reverts back to 1 again. My project partner didn't believe me until he experienced it himself!
So, recap:
I press the button which gets IN9 = 1, the setTemp goes up constantly because it stays, and the only way to get IN9=0 is if I disrupt whatever the heck is going on with my hand, which doesn't have to include physical touching of any wires or components.
Is there any way I can
1) Get the set temperature to go up by only one, for every time the state is at 1 (in other words, every time IN9=1 it goes up by only 1)?
2) Minimize this field (or whatever on earth is causing the problem)
heres the snippet of messy test code we have so far:
setTemp VAR Word
setTemp= 60
DO
IF(IN9=1)THEN
setTemp=setTemp+1
PAUSE 100
ENDIF
PAUSE 100
DEBUG CRSRXY, 6, 3, DEC setTemp, TAB, DEC IN9, CR
LOOP
Post Edited (Gaby D.) : 11/9/2009 9:16:26 AM GMT
Comments
DO
IF(IN9=1)THEN
setTemp=setTemp+1
PAUSE 100
ENDIF
PAUSE 100
DEBUG CRSRXY, 6, 3, DEC setTemp, TAB, DEC IN9, CR
LOOP
·Try this and see if this works better I know that you have your at Pin9 mine hook up on pin4
One Note if you hold the button it will keep going up by one until you release the button
' =========================================================================
'
'·· File......
'·· Purpose...
'·· Author....
'·· E-mail....
'·· Started...
'·· Updated...
'
'·· {$STAMP BS2}
'·· {$PBASIC 2.5}
'
' =========================================================================
'
[noparse][[/noparse] Program Description ]
'
[noparse][[/noparse] Revision History ]
'
[noparse][[/noparse] I/O Definitions ]
'
[noparse][[/noparse] Constants ]
'
[noparse][[/noparse] Variables ]
setTemp···· VAR······ Word
'
[noparse][[/noparse] EEPROM Data ]
'
[noparse][[/noparse] Initialization ]
·setTemp = 60
'
[noparse][[/noparse] Program Code ]
Start:
· DO
·· INPUT 4
·· DEBUG HOME, BIN1 IN4, " setTemp ", DEC· setTemp
·· IF IN4=1 THEN
·· GOTO start
ELSE
·· IF IN4=0 THEN
·· setTemp=setTemp+1
PAUSE 300
ENDIF
ENDIF
· LOOP
'
[noparse][[/noparse] Subroutines ]
I hope this helps
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 11/8/2009 3:05:09 AM GMT
Its a button, not a switch if it matters any.
··········································· · ··|
·········································· · ·^ . ...> 220 ohm·resister ....>·.PIN9······
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 11/8/2009 4:20:40 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Truth is out there············___$WMc%___···························· BoogerWoods, FL. USA
Post Edited ($WMc%) : 11/8/2009 3:27:09 AM GMT
You are right I did have the input floating I re did it the right way Thanks for pointing that out to me
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Hopefully one day I'll be knowledgeable enough to help people out too. [noparse]:)[/noparse]
Did that work for you the way you want it to work
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
But, I do have another programming related question.
We're assigning certain pins on the boebot to send out different voltages to an actuator to regulate a temperature. We want a range of temperature differences that would activate the pin. This is the code we used:
IF (currentTemp-setTemp) = (20 OR 19 OR 18 OR 17) THEN
HIGH 7
LOW 1
LOW 11
LOW 10
LOW 8
PAUSE 100
ELSEIF (currentTemp-setTemp) = (16 OR 15 OR 14 OR 13) THEN
HIGH 8
LOW 1
LOW 11
LOW 10
LOW 7
PAUSE 100
ELSEIF (currentTemp-setTemp) = (12 OR 11 OR 10 OR 9) THEN
HIGH 10
LOW 8
LOW 7
LOW 1
LOW 11
PAUSE 100
ELSEIF (currentTemp-setTemp) = (8 OR 7 OR 6 OR 5) THEN
HIGH 11
LOW 8
LOW 7
LOW 10
LOW 1
ELSEIF (currentTemp-setTemp) < 5 THEN
HIGH 1
LOW 11
LOW 10
LOW 8
LOW 7
ELSEIF currentTemp=setTemp THEN
LOW 10
LOW 11
LOW 8
LOW 7
LOW 1
PAUSE 100
ENDIF
it doesn't seem to work too well, any idea why?
We also tried something like ELSEIF (currentTemp-setTemp) <= 30, suggested to us by our professor, but that didn't work too well either.
We're all pretty frustrated with the code at this point, any ideas?
'*** The Right Way ***
TempDiff VAR WORD
TempDiff = CurrentTemp - setTemp
IF (TempDiff >= 17) AND (TempDiff <= 20) THEN
' *** The Wrong Way ***
The value of (20 OR 19 OR 18 OR 17) is a single number -- namely the value of 20 or-ed with 19, then that result
or-ed with 18, then that result or-ed with 17. 20 Decimal equals $14 Hex equals %00010100 binary. 19 decimal equals $13 Hex equals %00010011 binary. So %00010100 ORed with %00010011 is %00010111, == $17, == 23 Decimal.
Which I'm pretty sure is not what you wanted to do. So while in English it "sounds" right, mathematically it doesn't do what you wanted to do.
That means my professor was on the right track with his suggestion.
Now the program appears to work, but now the boe-bot (or SOMETHING) isn't. Each pin was individually tested to reassure connectivity, and they all work, but for some reason when I throw it all together with everything else it doesn't want to work.
I displayed the statuses of each pin on the debug screen to make sure the right pins were activated, and they are, but the actuator isn't responding in the associated manner. The only time the actuator will respond is if pin7 is active, and even then it opens to some place that we never calibrated. We have a chart of the voltage readings for when each pin is activated, and the number we're getting doesn't correspond with any of them. If we move the number out of pin7 territory, the actuator closes itself like its getting no voltage.
This project just doesn't want to reach full functionality!
Post Edited (Gaby D.) : 11/9/2009 7:03:55 PM GMT
You're going to need to describe your "actuator" in more detail.
Also the statement "if we move the number out of pin7 territory" is very vague. Do you mean "When TempDiff is not in the range 17 through 20"?
http://en.wikipedia.org/wiki/Actuator
We have a Proportional NSR ball valve actuator. You attach a ball valve to it, and itll open the valve proportional to the voltage you give it. Right now we have pins set up that will give off 0.6V, 0.68V, 0.95V, and 1.15V, each assigned to different pins that are triggered by the variable TempDiff.
And yes, that's what I mean. If TempDiff is not in the range that triggers pin7, it acts like its getting no voltage, and totally closes.
If the variable hits pin7s range, it gives us 0.9V, which is close to one of our values, but not the one assigned to pin7. Pin 7, when high, will give the actuator 1.15V.
·
ELSEIF (currentTemp-setTemp) = (16 OR 15 OR 14 OR 13) THEN
Try this routine also allanlane5 told you the same thing that what you have above will not work
ELSEIF (TempDiff··>·13)·AND ( TempDiff<·16)THEN
or
ELSEIF ( TempDiff·>·= 13)·AND (TempDiff·<·= 16)THEN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 11/10/2009 1:13:15 AM GMT
What I mean is, if you have 4 pins for 4 values, those values are driving the same valve, right?
If a pin is supposed to be on, but the others are set to LOW, your output voltage will be some resultant of all 4, and most likely lower than expected.
You may have to make sure any pin not being used is set to be an input so its high impedance won't affect the actual value you want.
A schematic would be a great help here.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·