thanks for replying. do you mean like this?:
http://i531.photobucket.com/albums/dd355/innerbreed/FSRconnection2.jpg
yes i agree. red, black and yellow are better.
fortunately i have loads of 24awg wire. unfortunately they all go from orange, purple, green, yellow, red, and blue.
Yep, totally understand about use the ones you got!
Yes your new picture look better. So when the switch is now closed, your Power will be connected to ground through the 10K resistor so not much current will flow and you can avoid the magic blue smoke
Kurt
thumbs up. thanks guys.
i have changed all the connection now so all is ok. just need my switches.
kurt i think you should have yours before mine as iv not yet got email back. good luck and i look forward to your progress.
here is the current code im using.
the probs i have is im not getting any response of the tars.
whats expected to happen:
The legs should be cycling though the gait then advance to the next leg once contact is made on previous leg.
The sound is beeping so i am getting a 0 reading from the sensor.
[code]
cRF_FSR con P16
cRR_FSR con P17
cLR_FSR con P18
cLF_FSR con P19
;Terain adaption sensors
cFSR sbyteTable cRR_FSR, cRF_FSR, cLR_FSR, cLF_FSR
:---------------------------------------------------
;Terrain adaption Get input from Tars pressure sensors
IF FSROn THEN
gosub ReadFSR
ELSE
RF_FSR =0
RR_FSR =0
LF_FSR =0
LR_FSR =0
ENDIF
;Balance calculations
TotalTransX = 0 'reset values used for calculation of balance
TotalTransZ = 0
TotalTransY = 0
TotalXBal = 0
TotalYBal = 0
TotalZBal = 0
IF (BalanceMode>0) THEN
for LegIndex = 0 to 2 ; balance calculations for all Right legs
gosub BalCalcOneLeg -LegPosX(LegIndex)+GaitPosX(LegIndex), |
LegPosZ(LegIndex)+GaitPosZ(LegIndex), |
(LegPosY(LegIndex)-cInitPosY(LegIndex))+GaitPosY+cFSR(LegIndex), |
LegIndex]
next
for LegIndex = 3 to 5 ; balance calculations for all Left legs
gosub BalCalcOneLeg [LegPosX(LegIndex)+GaitPosX(LegIndex), |
LegPosZ(LegIndex)+GaitPosZ(LegIndex), |
(LegPosY(LegIndex)-cInitPosY(LegIndex))+GaitPosY+cFSR(LegIndex), |
LegIndex]
next
gosub BalanceBody
ENDIF
:-------------------------------------------------
ReadFSR:
input P16;AX0 P16 V-Servo / General Purpose
input P17;AX1 P17 V-Logic / General Purpose
input P18;AX2 P18 General Purpose
input P19;AX3 P19 General Purpose
IF RF_FSR=0 THEN
LegPosY(cRF)=LegPosY(cRF+1)max 60
sound p9, [50\4000]
ENDIF
IF RR_FSR=0 THEN
LegPosY(cRR)=LegPosY(cRR+1)max 60
ENDIF
IF LF_FSR=0 THEN
LegPosY(cLF)=LegPosY(cLF+1)max 60
ENDIF
IF LR_FSR=0 THEN
LegPosY(cLR)=LegPosY(cLR+1)max 60
ENDIF
IF (RF_FSR+RR_FSR+LF_FSR+LR_FSR)>=6 THEN
RF_FSR = (LegPosY(cRF)-1) min 0
RR_FSR = (LegPosY(cRR)-1) min 0
LF_FSR = (LegPosY(cLF)-1) min 0
LR_FSR = (LegPosY(cLR)-1) min 0
ENDIF
;serout s_out, i57600, [sdec RF_FSR_PosY, 13]
return[/code]
battery’s just died!!! back to morrow with this.
Is FSR a new command in basic? Otherwise I’m not seeing where the input pins are set up. Maybe not needed?
New manual on BM.
Alan KM6V
He’s using the term FSR (force sensitive resistor) for the variables, but it’s actually just ground contact switches. Maybe it stands for Find Surface Reaction. lol
The code here…
[code]ReadFSR:
input P16;AX0 P16 V-Servo / General Purpose
input P17;AX1 P17 V-Logic / General Purpose
input P18;AX2 P18 General Purpose
input P19;AX3 P19 General Purpose
[/code]
Will not read anything. That code just makes the pins inputs. Make variables to store the results in, then fill them in with the values as follows.
FLS var bit ;Front Left switch
FRS var bit ;Front Right switch
RLS var bit ;Rear Left switch
RRS var bit ;Rear Right switch
ReadFSR:
FLS = in16
FRS = in17
RLS = in18
RRS = in19
i have defined the variables i just didnt post the obvious. sorry.
[code];[Terain adaption]
RF_FSR var bit
RR_FSR var bit
LF_FSR var bit
LR_FSR var bit
FSROn var bit[/code]
also should i change the sub
to
ReadFSR: ; Reading input from Foot Sensing Resistor
#_FLS = in16
#_FRS = in17
#_RLS = in18
#_RRS = in19
Does it work now?
Alan KM6VV
It compiles nicely…
But I will confirm any feedback tomorrow. The dreaded thing has happened… My battery’s need charging!
Well i thought id run some test on the code. all the legs are wired and as i haven’t got my switches yet (maybe next week) i thought id just see how the code is working. i have suspended the robot from the ground for this test just so i don’t accidentally make a connection with the tars that’s not intended. anyway,
START>the bot wakes up, TRIANGLE>gets it into walk pos, CROSS>turns the sensors on
here i was expecting the legs to start dropping as the wires are not >< connected on each tar?
Anyway, now the strange things start to happen…
if i say connected any one of the tars (simulated a FSR switch) the Rear right leg moves up about an inch and then drops again. and that happens with what ever tar i connect.
also if i connect the Rear left, then the Front left drops!
but then the other strange thing is that these reactions don’t always happen, sometimes they don’t react at all.
its safe to say the connections are correct as i do get a beep command when ever a Tar is connected and Disconnected.
im kinda thinking that the original code is just running its course and not letting the tars drop and i think the TA code just needs tweaking. i hope other have better luck. i will keep trying.
Terrain_V20.rar (32.8 KB)
So as I mentioned in the other thread. My parts arrived yesterday minus the three tubes I did not order. But since then I cut 3 from some 3" tubes I had from a previous version of the CHR-3 hex… So I will start to assemble them today. I am not sure I have enough wire, so may make a run to radioshack.
I am now trying to decide how I want to wire mine up. In your previous posts about how to wire it up, you are using a pull-up resistor. That is you are putting a 10K resistor between +5v and the signal pin. So when the switch is open you will have +5v going to the IO pin and when it is closed you will have 0V.
What I am thinking of doing is use a pull-down resistor. That is have the 10K resistor going between the signal pin and ground. So if I am correct when switch is open you will have 0V and when closed +5v. Does that make sense?
Also thinking about maybe trying to drill a hole in the L brackets and maybe trying to insert an LED and wire it up with the switch. Need to figure out the wiring and the like, but might be nice to see the LED go or or off when contact is made…
Kurt
A pull up pulls the signal high if it is not connected to ground. This is required because one side of the switches are tied directly to chassis ground, and this can’t change. A pull down would require a connection to 5vdc on one side of the switch to force it high when engaged.
I connected the resistor between the 5v and the I/O pin, one end of the contact switch to ground, and the other switch wire to the I/O pin.
Then the resistor keeps the I/O pin at 5v until the switch is closed.
figure that the legs will be on the floor most of the time.
http://i531.photobucket.com/albums/dd355/innerbreed/FSRconnection2.jpg
Referring back to your August 14th post, it looks from that diagram that you should switch the yellow and black wires.
[PS: kurte already mentioned this change in his post, but your recent diagram didn’t seem to reflect the change. My apologies if you’ve already done so.]
The wire from the outside of the Ground Contact Switch is connected to the chassis, which is usually grounded. In this case, the black wire will always be at ground and the sensor input will also always be low. Hence the black wire should be connected to the system ground and not the microcontroller I/O pin.
The yellow wire (connected inside the ground contact switch) floats electrically when the leg is lifted. It should be connected to the microcontroller I/O pin.
If these two wires are connected in this manner, when the leg is on the ground, the yellow wire will be grounded and the signal will be low; when the leg is lifted, the yellow wire is not connected to anything and the pullup resistor makes the signal high.
for the purpose of the picture i used black and yellow. i actually have just black and red. (i ordered more wire)
Red wire is now connected to the I/O pin along with the pull-up going to 5v.
Black wire is going to ground and is grounded to the chassis.
the connections are as shown but the colors are different.
Mine------Picture------Connection
RED.......Black........I/O pin+ Resistor to 5v
BLACK.....Yellow.......To Ground+ chassis
http://i531.photobucket.com/albums/dd355/innerbreed/FSRconnection2.jpg
But how is the red/black wire connected to the Ground Contact Switch?
Is the red wire, which is connected to the IO pin on the microcontroller board with the pull-up resistor, connected to the internal contact on the Ground Contact Foot Switch?
Been doing some work with the FSR’s and i have got the sensors work as far as i have a reaction from them when i simulate them switching.
when you start up the robot the the feet drop just below the 0 initpos position (-initpos). when the robot feel the ground they return to the 0 initpos.
so with that said, when the robot is on the ground it sits at it 0 initpos and once it makes a step and moves over a lower part of the ground the foot moves below the initpos to the -initpos.
the only problem is its either up or down and no happy medium. also once the tars feel the floor they bounce up staight away.
here is the code.
IF RR_FSR=0 THEN
LegPosY(cRR)=-LegPosY(cRR+1)max 100
; sound p9, [50\4000]
elseif RR_FSR=1
LegPosY(cRR)=0
else
RR_FSR = (-LegPosY(cRR)-1) min 0
ENDIF
so i have tried adding a command to save the state of the leg but its not working for me. here is what i was thinking.
[code] ;If foot up
IF RF_FSR=0 THEN ;Lower legs
LegPosY(cRF)=-LegPosY(cRF+1)max 100
; sound p9, [50\4000]
elseif (RF_FSR=0) ;if foot up
LegPosY(cRF) = cInitPosY(cRF)+cFSR
;Store current status
prev_RF_FSR = RF_FSR
ELSE ;Return prev leg back to the init position
LegPosY(prev_RF_FSR) = cInitPosY(prev_RF_FSR)
ENDIF[/code]
with this im just getting the same response.!
any tips on how this should be written.
id like the tars to drop slowly to the floor when they detect they have been elevated, then they stay at their position once the floor has been found. once the leg lifts, the tars need to return to their initpos again.