ok, now I allso got my UBECs … only waiting for the servos
I am experimenting with the Sharp IR (infra red , searchengine remark) range sensor GP2Y0A21YK0F (2Y0A21) 10 to 80 cm
[code]pot var word
cRanger con P8 ;
main
adin cRanger, pot ;read analog pin P0, load result into POT
hserout [0, "Analog Value = ", dec pot]
Pause 50[/code]
After careful probing the math between ARC32 analog reading (a), with is 0-1024, and the range in cm ® is
r = (a to the power of -1,245) * 20923
This has taken me all night because i am a forgetfull and unskilled, after all it vas 25 years since i did any advanced math
Now now when i felt so good over myself i was going to write a easy fast program to convert thr reading to cm
… and i have no clue how to do it, according to the Basic Micro Manual it cant be done since it cant directly handle this high math, and then you have to be even brighter (then me) if you are going to use Basic Micro th calculate it because you have to do it someotherway…
i thing i am ready for a converttable now instead …
these snippet’s of code are from the phoenix v2 code…I don’t know if they will help because I don’t know what they are doing I just use them.
; This table is used to convert Sharp IR readings into CM
IRCMTable bytetable 80,80,80,80,80,80,80,80,80,78, |
76,74,72,70,68,66,64,62,60,59, |
58,57,55,53,52,51,50,49,48,47, |
45,43,42,41,40,39,38,37,35,33, |
32,31,30,30,29,29,28,28,27,27, |
26,26,26,25,25,25,24,24,24,23, |
23,22,22,21,21,20,20,20,19,19, |
18,18,18,17,17,16,16,16,15,15, |
15,14,14,13,13,13,12,12,11,11, |
11,10,10,10,10,10,10,10,10,10
;--------------------------------------------------------------------
;IR input converted to CM’s
GetIRScanInCM[IRPin]
; first read in the IRvalue.
adin P0,scanrange
; If it is greater than 512 it is out of range we will return 0
IF scanrange > 512 THEN ; outside our table so return 0 to signal too close
return 0
ENDIF
; now convert entry to cm from table. Old program
; divided value by 5.12 using floating point, but could simply multiply by 100 and divide by 512
; in integer math, which should be a lot quicker. 512100 < 65536 so fits in word…
return IRCMTable((scanrange10)/512)
I did it like this instead
[code]
;var
cRanger con P8 ;
IRconverttable bytetable 80,75,70,65,60,55,52,50,48,46,44,42,40,38,36,34, |
33,32,31,30,29,28,27,26,26,25,24,24,23,22,22,21, |
21,20,20,20,20,19,19,18,18,18,17,17,17,16,16,16, |
16,15,15,15,15,14,14,14,14,13,13,13,13,13,12,12, |
12,12,12,12,12,11,11,11,11,11,11,10,10,10,10,10, |
10,10,9,9,9,9,9,9,9,9,9,8,8,8,8,8,8,8,8,8
Result var word
;begin
main:
hserout [0,“Testing”, 13]
GOSUB GetIRDistance[cRanger], Result
hserout "Distance (cm) = ", dec Result, 13]
Pause 40
goto main
;[GetIRDistance]
IRMeasurePin var byte
GetIRDistance[IRMeasurePin]
;var
IR_RangeCm var word
IRMeasureIn var word
;begin
adin IRMeasurePin, IRMeasureIn
if IRMeasureIn < 88 then
IRMeasureIn = 89
endif
IRMeasureIn = IRMeasureIn -88
IR_RangeCm = IRconverttable((IRMeasureIn) * 100 / 487)
if IRMeasureIn > 487 then
IR_RangeCm = 7
endif
return IR_RangeCm[/code]
And for thouse of you, who like me, cant find any examplecode to get the SRF01 ultrasonic rangefinder (Devantech) working
This is my code:
[code]-------------------------
Gosub GetUSDistance
INIT:
cUSRanger con P1 ;
result var word
USAGE:
GOSUB GetUSDistance[cUSRanger], Result
hserout [0,"Distance (cm) = ", dec Result, 13]
SUB:
;[GetIRDistance]
USMeasurePin var byte
GetUSDistance[USMeasurePin]
;var
wDist var word
wDistTemp var word
;begin
low USMeasurePin
Pause 2
High USMeasurePin
serout USMeasurePin ,i9600,[1,84]
serin USMeasurePin ,i9600,[wdist.highbyte,wdist.lowbyte]
return wDist/2[/code]
We have an announcement (like a sticky) on the Bot Board & BASIC Atom Pro category called Atom Pro example code (sensors/sound) and it has two examples for using the SRF-04.
thats maby why i didnt find it when i searched for SRF01 …
no problem, allways nice with some brainwork and an oppurtunity to train those BASIC-braincells…
I have two worries:
1:I havnt gotten the (serial) SRF01 and the (analog) 2YOA21 to work, and not yet the (serial) 20x4 Display, and worry one is how these sensors, especially the serial ones will react whith 18 servoes running whith thousands of interrupts each second …
forums.basicmicro.net/atompro-f4 … 85fbb28b2a
2: I cant get the serial communication over UART2 to work whatever i do, neither with BMS built in terminal not with Putty.EXE (what i usually use)
I just do an ordinaly INIT : SetHSerial2 H57600,H8DATABITS,HNOPARITY,H1STOPBITS
and then i try to print using: hserout 2, “Distance (cm)”, 13]
All i get in garbage, not the same garbage in those two programs, but still garbage
I am connected using a USBtoSerial … many it is thatone that is making the broblem … but i dont know, and i have a simple three-part-cable (TX,RX and ground) in between … i dont think it is that one, because the cabels are connected just as i THINK it shall be…
Oops I thought you were looking for SRF-04. Sorry…
I believe this was the same issue we discussed on the Basic Micro forum. The problem is that you are connecting up the TX2/RX2 TTL level signals directly up to an RS232 cable which is expecting/outputting RS232 level signals… Need something like a MAX232 chip to do the translations… or could connect up to something else that is expecting TTL level signals like Xbees (Warning these expect 3v so you need voltage translation boards, like sparkfun or parallax boards), or Bluetooth or…
Or If you are also using an SSC-32 as well and you have removed the jumpers for using the 9 pin connector as to hook up the SSC-32 to your processor… You can jumper over from the BB2 to the output parts of the SSC-32 and use it’s voltage level chip to output RS232 level signals… But I am assuming you are strictly using Arc32…
Kurt
Yes, i took the discussion on BasicMicro because i thought there where a serious chance either there where somethin wrong whith the card (i really did a serious investigation), or i didnt get how to connect it (my idea as I where missing some pins)
… but the onlky hardware failing was me ! 8)
I think i need an instruction what to buy and how to use the XBEE to be able to use it as a remote wireless debugterminal
I have gotten the 4x20-display to work … but it is alittle nonconsistent it its function… bu t will investige alittle further before complaining…
Makes sense to go up to Basic Micro… There are a couple of people up there that know some of the hardware stuff…
As for XBees, I use them on all of my bots, since I converted the DIY remote control to XBee. There are many places to purchase them. I purchased most of mine from Sparkfun, but later purchased some stuff from Parallax. There is a complete starter setup you can purchase from Trossen (forums.trossenrobotics.com/tutor … sics-3259/
As you can tell, I like to play with different processors and I have had problems with the sparkfun adapter on some of them. One of them was the Axon2 which is an ATmega 1280 based board. It turns out that the sparkfun board down shifts the 5v down to the 3.x v needed by the XBee, but it did not up shift the voltage from the XBee going back and the voltage for high was not high enough… On these boards I have had better luck with adapters like: parallax.com/StoreSearchResu … fault.aspx
Note as for LCD display working… That is most likely an issue with the text being corrupted by the processor due to processing an interrupt. If you can get the display configured to a low speed like 2400 than you stand a chance… Note if you use HSERVO there will be tons of interrupts, if you use HSERIAL you will get an interrupt on every character that is sent or received… That is why on my DIY XBee code there is some hacks for those robots that use SSC-32. When we are about to output to the SSC-32, I disable my timer, also when I wire up the XBEE I hook up an RTS line and I pull this low to tell the xbee not to send me anything, I may also have my code wait until the XBEE output queue is clear before I start outputting to the SSC-32…
I hope I answered your questions.
Kurt
WOW. im jealous. 8)
Please Observe:
There are a difference between the product
Aluminum Long “C” Servo Bracket with Ball Bearings Two Pack
and
Aluminum Long “C” Servo Bracket Two Pack
i didnt …
The name sort of gives it away … but i obviously didnt understand it…
I cant get hand on 3x8x4 so ive orderd 4x8x3, Ill just havto make the screwhole alittle larger so i can fit a M4
… and talking about M4, i cant really se myself fastening all servos in the four 4,3mm servoears using M3 screw … so Ive upgraded do M4 there allso, and I think I’ll connect the consoles with 4 screw/nut instead of the instructed 2, because if i later finds a reason to need 4 Ill hawto take all legs apart … not a job i look forward to
http://nc.sverige.net/nc/robot/M4Servoscrews.JPG
and i found a small monkeywrench to keep me company (built from a swedish patent since 1891)
http://nc.sverige.net/nc/robot/MonkeyWrench.JPG
… they are everywhere !!
This is where i am now:
The body and its leg are assembeled and installed (hopefully) the right way
http://nc.sverige.net/nc/robot/DSC09311.JPG
And the head is assembled and installed on the tilt-kit
http://nc.sverige.net/nc/robot/DSC09337.JPG
My idea was to build a head that looked like an old Kodac Instamatc-kamera, but my ten yeared daughter insisted ill keep the “ears” and later install some kind of gold earring or something … aint daughters wonderfull !!
Iv buildt a “floor” and put the UBEC’s and the fuses on it, and shortend a USB-cable
http://nc.sverige.net/nc/robot/DSC09340.JPG
http://nc.sverige.net/nc/robot/DSC09343.JPG