Show Posts
|
|
Pages: [1] 2
|
|
1
|
Forum 2005-2010 (read only) / Troubleshooting / Re: can't get two urm37 (ultrasonic) sensors to work
|
on: November 09, 2010, 02:07:42 am
|
Here is the layout and distance chart I made from the urm32 reference.  Wiring Sensors to RoboDruino: Using the interfacing URM37 to Robodruino photo from yerobot as reference. Each URM37 requires Red(+5V),Black(GND),Green(UltraData),Yellow(UltraTrigger)P10 and Blue(UltraEnable)P9 total of 5 fly leads per sensor. My friend Bruce made a suggestion to make a few paired or double leads [(+5v),GND],[UltraTrigger and UltraEnable] that go from Robodruino to all 4 sensors in a chain to save alot of PWM i/o's and single F-F fly leads. Thanks to Bruce who soldered me some 4 way fly leads for this purpous using salvaged pc front panel wires and ends. Using the method described above I have saved 4 fly leads per sensor, so I only require 1 for the Green(UltraData) as a result I have the right amount of PWM i/o's for 4 sensors simultaneously on a single Roboduino. Here is the wiring loom diagram of how I linked the 4 urm32 sensors together.  The fly leads I saved I will use in future Versions as I hope to make use of the URM37's built in servo angle control pins next to independantly tilt each URM37 with my servos using an adapted for Robodruino servo controlling proto-sheild. I will just use the head rotation of my robot to handle the sensors pan and robots my pan/tilt ultrasonics will be almost complete. Code changes and challenges: As a result of the wiring looms I can Power, Enable and Trigger all four sensors together from the same line. Basically I broke the original code up into 4 sections, Activate Trigger, Read High, Read Low and Display Data. then I refined from there. One of the challenges I faced duplicating this code for the 4 directions was trying to run four loops concurrently was giving false readings and accuracy seemed to be effected by changes therefore another friend Big Al suggested to break it up into Functions that I call later as I need, this seems to have worked great. Now I have each sensors data being passed to the LCD via serial I am now working on sending the data to an arduino controlling my sure24x16 Led display to represent the distances in a more meaningful way. I will post this project in its own thread soon.
|
|
|
|
|
2
|
Forum 2005-2010 (read only) / Troubleshooting / Re: can't get two urm37 (ultrasonic) sensors to work
|
on: November 08, 2010, 02:05:41 pm
|
URM37 Ultrasonic/Temperature Sensor ver3.2 (5m sensor)Downloaded the original code from yerobot.com First written by Ricky on 2008 08 13, modified by Crystal on 2008 09 27 Original Code Description-[Reads values from an ultrasonic sensor and writes the values to the serialport.] Thanks to Yerobot for Hardware and Original Example Code. New Version written by Adz on 22 11 2008. Thanks also to Arduino Reference Coders you all helped heaps. needed to rewrite provided example code to use 4 sensors. I Changed ultraData variables to include the 4 sensors in position mounted on my robots head. New code Gives 4 independant simultaneous distances from 4 cardinal directions(ie:North,South,East,West) Using the interfacing URM37 to Robodruino photo from yerobot as reference. Each URM37 requires Red(+5V),Black(GND),Green(UltraData),Yellow(UltraTrigger)P10 and Blue(UltraEnable)P9 total of 5 fly leads per sensor. My friend Bruce made a suggestion to make a few paired or double leads [(+5v),GND],[UltraTrigger and UltraEnable] that go from Robodruino to all 4 sensors in a chain to save alot of PWM i/o's and single F-F fly leads. Using the method described above I have saved 4 fly leads per sensor, so I only require 1 for the Green(UltraData) as a result I have the right amount of PWM i/o's for 4 sensors simultaneously on a single Roboduino. can supply a wiring diagram and the sensor map I made also if you like. // // Code Begins. // Variable Declarations int aCount = 0; // Array Counter--variable counts zero to 3(allow for zero indexing) int lCount = 1; // Loop Counter-variable to test how many loops int tCount = 1; // Trigger Counter-debug variable to test how many triggers per loop int sensorDirection=4; // Ultrasonic Sensor Location Direction,1=Front,2=Rear,3=Left,4=Right int val[5]={0,0,0,0}; // values by direction int timeCount=0; // Ultrasonic Echo counter int ultraValue[5]={0,0,0,0}; // sets intial values to zero // Robodruino Pin Designations int ultraData[5]={11,6,5,3}; // Ultrasonic data pins 11=Front,6=Rear,5=Left,3=Right int ultraTrigger=10; // Ultrasonic trigger pin int ultraEnable=9; // Ultrasonic enable pin int ultraPower=12; // Ultrasonic power pin int ledPin = 13; // LED connected to digital pin 13 // Create New Function int ActivateTrigger(){;//>>>>>>>>Function - ActivateTrigger() -// Called each loop to Trigger Ultrasonic Pulse. tCount++; // Increment Trigger Counter pinMode(ultraTrigger,OUTPUT); // Switch signalpin to output /* Send high-low-high pulse to activate the trigger pulse of the sensor * -------------------------------------------------------------------*/ digitalWrite(ultraTrigger,HIGH); // Send high pulse HIGH delayMicroseconds(500); //Can be trimmed to 64 to speedup,adz.Orignal Value 500. digitalWrite(ultraTrigger,LOW); // Send low pulse LOW delayMicroseconds(200); //Can be trimmed to 26 to speedup,adz.Original Value 200. digitalWrite(ultraTrigger,HIGH); // Send high pulse HIGH delayMicroseconds(200); //Can be trimmed to 26 to speedup,adz.Original Value 200. }//>>>>>>>>End Function - ActivateTrigger().
void setup() { Serial.begin(9600); // Sets the baud rate to 9600 pinMode(ledPin,OUTPUT); // Sets the digital pin as output pinMode(ultraPower,OUTPUT); // Sets Power On to sensors digitalWrite(ultraPower,HIGH); // Set to HIGH to provide 5V power pinMode(ultraEnable,OUTPUT); // Sets the digital Enable pin as output digitalWrite(ultraEnable,HIGH); // Set Enable Pin to HIGH delay(200);//Can be trimmed to 50 to speedup,adz.200msGive sensor some time to start up --Added By crystal from Singapo, Thanks Crystal. } void loop() { // Main Loop digitalWrite(ledPin,LOW); // Switches off Led Hearbeat Pin to Low aCount = 0,lCount=1,timeCount=0,sensorDirection=4;// Sets Array count to start at zero index, Loop count aligns Sensor Value to correct Array int combine; // Initialize Combine Variable to enable calling Functions from within the Loop for(lCount=1;lCount<=sensorDirection;){// Loops thorugh sensor1(Front),sensor2(Rear),sensor3(Left),sensor4(Right), if (aCount>3) {aCount=0;} // Ensures Array stays between 0-3 to align to Correct Sensor val[aCount]=0; pinMode(ultraData[aCount],INPUT); // Switch signalpin to input combine=ActivateTrigger(); // Calls ActivateTrigger() Function to command Sensors Ultrasonic Ping to happen prior to each reading. // while sensor output is HIGH do update Value while (digitalRead(ultraData[aCount])==HIGH) {val[aCount]=digitalRead(ultraData[aCount]);} // if read HIGH update Value // while sensor output is LOW do update Value, increment timecount and delay(dont change delay alters values somehow) while (digitalRead(ultraData[aCount])==LOW) {val[aCount]=digitalRead(ultraData[aCount]),timeCount++,delayMicroseconds(50);} // if read LOW update Value ultraValue[aCount]=timeCount; // Append echo pulse time to ultraValue[aCount] // //not sure if these LCD commands will effect anything else // Serial.write(254,HEX),Serial.write(1,HEX); //Clear the LCD(seetron users manual commands) // Serial.write(254,HEX),(2,HEX); //Set the LCD cursor to home // Serial.write(254,HEX),(2,HEX); //Set the LCD cursor position to top left // Serial.write(254,HEX),(192,HEX); //Set the LCD cursor position to bottom left // // URM37 Datasheet "Pin PWM will output pulses every 50us represents 1cm,If the reading is invalid, a 50000us pulse will be returned." // Need an Error Trap here for Sensor Readings out of range. something like if error then tell me else display reading. // if ultraValue[acount]<4||if ultraValue[acount]>5000 then Serial.print("Error") // if distance < min possible reading(4cm) or distance > max possible reading(5000cm) then must be invalid reading or error if (aCount==0) {Serial.print(" Fr="),Serial.print(ultraValue[aCount]);} // Display Read Value for Front Sensor Array0 else // Loop is not Front Sensor if (aCount==1) {Serial.print(" Re="),Serial.print(ultraValue[aCount]);} // Display Read Value for Rear Sensor Array1 else // Loop is not Rear Sensor if (aCount==2) {Serial.print(" Le="),Serial.print(ultraValue[aCount]);} // Display Read Value for Left Sensor Array2 else // Loop is not Left Sensor if (aCount==3) {Serial.print(" Ri="),Serial.print(ultraValue[aCount]);} // Display Read Value for Right Sensor Array3 Serial.flush(); // flush the serial buffer if(ultraValue[aCount] > 20){digitalWrite(ledPin, HIGH);} // Lite up LED if any value is passed by the echo pulse aCount++;lCount++;} // increment Array Counter and Loop Counter delay(500); // Delay of program return; // Return to Start of Loop }// //Code Ends.
|
|
|
|
|
4
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: Help with Serial Output
|
on: November 13, 2010, 11:58:19 am
|
|
I am still learning myself but if you want only 0 and 1 output perhaps change the variable to be a binary value by putting ,bin after it. IE: Serial.print(incomingByte,BIN); its listed in the reference under serial.print. I hope that helps a little.
|
|
|
|
|
5
|
Forum 2005-2010 (read only) / Syntax & Programs / Seeking advice about my robots URM32's code.
|
on: November 12, 2010, 10:30:21 pm
|
I am Seeking advice about my robots URM32's code and the electronics setup. I am currently in the process of building a fullscale R2D2 styled robot I have called R0D0 as it is supposed to be retro looking like a great great grandfather astromech driod. I have 3 x Urm32 sensors setup on home made servo driven Pan/tilt mechanisms. There are several things I need advice on to acheive the result I want from this code, setup of wiring loom and pin assignments from both robodruino to sensors and the serial connection from robodruino to arduino best practises and recommended methods for my processors and attached sensor devices taking in to account all loads and tolerances. (I am concerned my setup is asking too much of my robodruino somehow, 3 sensors and LCD drawing too much or data stream overloading serial port perhaps?) optimise the distance measuring and streaming serial data values loop / routine. write code to enable the temperature function for each sensor to stream the values via serial along side the existing distance value. effectively impliment the servo control functions I have written of each sensor relative to its pan/tilt unit within the limitations of the locations. optimise the sure 24x16 led code I have written to represent/visualise the distance value and ping sonar wave shape similar to the chart in my other post. If you are interested to help message me and I will send you the code for the led display, The code for my distance measuring and wiring diagram is already posted in another thread about running multiple Urm32's here. http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1288429609/11#11Any constructive advice would be apreciated. Padwan Learner in the ways of the Arduino, Adz.
|
|
|
|
|
8
|
Forum 2005-2010 (read only) / Troubleshooting / Re: Problem Uploading to board, avrdude not in sync
|
on: November 11, 2010, 01:36:20 pm
|
Are you sure this is the right baud rate?
Can you tell me how to check if this is the "right baud rate" All the code I have used so far used 9600 as my baud rate for my serial ports. I really hope my robodruino is not "dead" as I can see no way that I have "killed" it. was running test code fine for the past few weeks. then just the same error over and over.
|
|
|
|
|
9
|
Forum 2005-2010 (read only) / Troubleshooting / Problem Uploading to board, avrdude not in sync
|
on: November 11, 2010, 12:15:39 pm
|
Today I had my 1st serious problem with an arduino, can anybody clarify the solution to this issue? I had code running on my robodruino that loops sensor values to the serial port to pass to an arduino. Now I cannot upload to the robodruino at all. tried taking it apart back to just usb cable, changing usb ports, installing latest drivers. Still dead, If Any Arduino Gurus can help I and many others would apreciate it alot. I am running Win7-64bit, Arduino 21 Error reads, Problem uploading to board. avrdude: stk500_getsync(): not in sync: resp=0x00 avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51 Verbose Error output, avrdude: Version 5.4-arduino, compiled on Oct 11 2007 at 19:12:32 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ System wide configuration file is "H:\Adztemp\Arduino\arduino-0021\arduino-0021\hardware/tools/avr/etc/avrdude.conf" Using Port : \\.\COM1 Using Programmer : stk500v1 Overriding Baud Rate : 19200 avrdude: ser_open(): setting dtr avrdude: Send: 0 [30] [20] avrdude: Send: 0 [30] [20] avrdude: Send: 0 [30] [20] avrdude: Recv: avrdude: stk500_getsync(): not in sync: resp=0x00 avrdude: Send: Q [51] [20] avrdude: Recv: avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51 avrdude done. Thank you.
|
|
|
|
|
10
|
Forum 2005-2010 (read only) / Interfacing / Re: Arduino to 384 LED display module (MCU Interface)
|
on: December 22, 2010, 12:30:00 pm
|
|
If you use my code on page 23 you can see which co-ordinate changes are required if your adressing is different, my older display adressing is like this ; // Column1 Column2 Column3 Y coordinate number // |00000000||00000000||00000000|0 // |00000000||00000000||00000000|1 // |00000000||00000000||00000000|2 // |00000000||00000000||00000000|3 // |00000000||00000000||00000000|4 // |00000000||00000000||00000000|5 // |00000000||00000000||00000000|6 // |00000000||00000000||00000000|7 //Top X coodinate 22 to 15] // Top left middle right 8x8's // |00000000||00000000||00000000|8 // |00000000||00000000||00000000|9 // |00000000||00000000||00000000|10 // |00000000||00000000||00000000|11 // |00000000||00000000||00000000|12 // |00000000||00000000||00000000|13 // |00000000||00000000||00000000|14 // |00000000||00000000||00000000|15 //Bottom X coodinate 22 to 15 ] // Bottom left middle right 8x8's
If you edit the X coordinate in my code you can see where your displays adress is different from mine. As the values on mine start at -1 not zero as I 1st assumed it would be. My display values ascend as in the above diagram from -1 to 22, I hope this helps you find the values for your X coordinates. Also I have found the newer displays are different values from my old display. I would be interested what other people found they need to use for the X values to display in thier columns in order correctly? Maybe the swapped columns you refer to are because of the X coordinate value?
|
|
|
|
|
12
|
Forum 2005-2010 (read only) / Interfacing / Re: Arduino to 384 LED display module (MCU Interface)
|
on: October 28, 2010, 12:13:06 pm
|
Its my 1st post here, I hope this code helps somebody I know it did me to write it, also I have some questions about taking the serial data from my robodruino and passing it to my adruino contolling my 24x16matrix. Also very interested if somebody can explain simply how to shorten the length of the demo bitmap data area in the demo16x24scroll by WestfW. I have made my own data for this but I cant identify what variable makes the area size for the bitmap? The demo data is the ladybits and I want to use less area than it uses somehow. would apreciate any help. Adz // FigureOut Sure2416 v1.0 // Sure Green 24x16 Adz Kiss version. // Copied ideas from all the Example democode and documentation I could find. Unfortunately found some examples would not work. // Read many Adruino Forum threads and I noticed that many people like me found the example code hard to read and were // asking for a kiss style explination of what is going on, I found to do this was enlightening in many ways about the // board especially the offset referred too in the code but was hard to envisage, I hope this helps others to do so and // clarify things about this board, mine is the oldest style green one from sure. // I would especially like to understand the many function libraries and thier uses created by Miles Burton,Bill Westfield,etc,etc. // I am trying to make my own font files with his notes with limited success. // However from reading the forums its not easy to figure out thier great work, for many like me still learning as we go. // Much Respect, Many Thanks and of course all apropriate Credits etc to all creators and contributors for thier // respective efforts and code snippets. // Premise is that board is divided into six 8x8 led modules arranged in 2high 3wide // this creates 3 columns of 8leds wide by 16 high comprised of 6 individual (8x8 led modules) // Column1 Column2 Column3 Y coordinate number // |00000000||00000000||00000000|0 // |00000000||00000000||00000000|1 // |00000000||00000000||00000000|2 // |00000000||00000000||00000000|3 // |00000000||00000000||00000000|4 // |00000000||00000000||00000000|5 // |00000000||00000000||00000000|6 // |00000000||00000000||00000000|7 {76543210 16 to 8 25 to 17?why not this?} //Top X coodinate number [6543210-1 14 to 7 22 to 15] not phone number as the website assumes // Top left middle right 8x8's // |00000000||00000000||00000000|8 // |00000000||00000000||00000000|9 // |00000000||00000000||00000000|10 // |00000000||00000000||00000000|11 // |00000000||00000000||00000000|12 // |00000000||00000000||00000000|13 // |00000000||00000000||00000000|14 // |00000000||00000000||00000000|15 //Bottom X coodinate [6543210-1 14 to 7 22 to 15 {wierd offset? are they all like this?) // Bottom left middle right 8x8's // I used this style of template as a key to the led on(*) and off(0) in the code. // I will refer to the led positions in this format to clarify the led positions in relation to x,y adressing in code. // I will add variables to use as columns later to display sensor data as 3 line graphs using the bars in this demo. // My actual use for my display board and this code is to attempt to display visually the 3 Ultrasonic pings of my robot. // I have 3*URM37 Ping sensors running on a robodruino, I hope to pass the data from them to this code in the future. // I am working on representing the shape of the ultrasonic waves from my 3 sensors this way using the pulse fade effect. // hopefully between brightness levels and 16 divisions I can represent my 3 distance sensors #include "Sure2416.h" void setup () // flow chart from page 17 of datasheet { ht1632_displayInit(); ht1632_clearScreen(); } void columnon() { ht1632_clearScreen(); byte x,y, bits; char intensity; for (x=24,y=16;y>=0;y--) {// as this loop decrements starting at 16 lines draw on bottom rows working up each time y goes down // therefore if y is >8 then in bottom panel for (intensity=0; intensity <= 14; intensity++) { // intensity lowest to highest ht1632_sendcmd(HT1632_CMD_PWM + intensity); delay(LONGDELAY/64); // change the pulse intensity lowest to highest speed here,4/8/15/32/64/128/256 I tried them all } //Bottom Panels starts here // 6543210-1 (coordinatex) // Led Positions on Line on bottom left 8x8 ht1632_setPixel(-1,15+y,1); // 0000000* strange thing is left column extreme right led requires -1 to set on ht1632_setPixel(0,15+y,1); // 000000*0 zero starts on 2nd led from right ht1632_setPixel(1,15+y,1); // 00000*00 then they go across back towards the left ht1632_setPixel(2,15+y,1); // 0000*000 as you increase x value ht1632_setPixel(3,15+y,1); // 000*0000 this offset seems very odd to me ht1632_setPixel(4,15+y,1); // 00*00000 I wonder if all of them are wired/setup this way? ht1632_setPixel(5,15+y,1); // 0*000000 Never thought I would need to use a -1 was surprized. ht1632_setPixel(6,15+y,1); // *0000000 // draw line at base of middle column on bottom middle 8x8 ht1632_setPixel(7,15+y,1); // 0000000* ht1632_setPixel(8,15+y,1); // 000000*0 ht1632_setPixel(9,15+y,1); // 00000*00 ht1632_setPixel(10,15+y,1); // 0000*000 ht1632_setPixel(11,15+y,1); // 000*0000 ht1632_setPixel(12,15+y,1); // 00*00000 ht1632_setPixel(13,15+y,1); // 0*000000 ht1632_setPixel(14,15+y,1); // *0000000 // draw line at base of right column on bottom right 8x8 ht1632_setPixel(15,15+y,1); // 0000000* ht1632_setPixel(16,15+y,1); // 000000*0 ht1632_setPixel(17,15+y,1); // 00000*00 ht1632_setPixel(18,15+y,1); // 0000*000 ht1632_setPixel(19,15+y,1); // 000*0000 ht1632_setPixel(20,15+y,1); // 00*00000 ht1632_setPixel(21,15+y,1); // 0*000000 ht1632_setPixel(22,15+y,1); // *0000000 { if (y<=8&&y>=0){// if y is <=8 then line position in top panel // yes I could have 1/2ed the code here but its the Kiss version. //Top Panels starts here// Led Positions on Line across each column // 6543210-1(coordinatex)// left column on top left 8x8 ht1632_setPixel(-1,15+y,1); // 0000000* anybody else think this is strange? right led requires -1 to set on ht1632_setPixel(0,15+y,1); // 000000*0 ht1632_setPixel(1,15+y,1); // 00000*00 ht1632_setPixel(2,15+y,1); // 0000*000 ht1632_setPixel(3,15+y,1); // 000*0000 ht1632_setPixel(4,15+y,1); // 00*00000 ht1632_setPixel(5,15+y,1); // 0*000000 ht1632_setPixel(6,15+y,1); // *0000000 // middle column middle 8x8 middle column on top middle 8x8 ht1632_setPixel(7,15+y,1); // 0000000* ht1632_setPixel(8,15+y,1); // 000000*0 ht1632_setPixel(9,15+y,1); // 00000*00 ht1632_setPixel(10,15+y,1); // 0000*000 ht1632_setPixel(11,15+y,1); // 000*0000 ht1632_setPixel(12,15+y,1); // 00*00000 ht1632_setPixel(13,15+y,1); // 0*000000 ht1632_setPixel(14,15+y,1); // *0000000 // right column right 8x8 right column on top right 8x8 ht1632_setPixel(15,15+y,1); // 0000000* ht1632_setPixel(16,15+y,1); // 000000*0 ht1632_setPixel(17,15+y,1); // 00000*00 ht1632_setPixel(18,15+y,1); // 0000*000 ht1632_setPixel(19,15+y,1); // 000*0000 ht1632_setPixel(20,15+y,1); // 00*00000 ht1632_setPixel(21,15+y,1); // 0*000000 ht1632_setPixel(22,15+y,1);} // *0000000 } for (intensity=14; intensity >= 0; intensity--) { // intensity highest to lowest ht1632_sendcmd(HT1632_CMD_PWM + intensity); delay(LONGDELAY/8); // change the pulse intensity highest to lowest speed here,4/8/15/32/64/128/256 I tried them all } } } void loop () { columnon(); }
|
|
|
|
|
14
|
Forum 2005-2010 (read only) / Interfacing / Powertip PC1602Q B 2*16 character LCDDisplay Panel
|
on: November 09, 2010, 06:15:36 am
|
|
I purchased a Powertip PC1602Q B with 2*16 character Display Panel LCD Module with a Seetronics LCD Serial Backpack and attempted to connect it to the RoboDruinos Pin2(TX) to read the Data, However this proved to be a challenge itself because all I got was garbled hyreglyphics. After some research Bruce discovered for some reason the Serial Traffic of all Adruino boards is inverted. Therefore; a circuit needed to be created to invert the data stream of the Robodruino to make it readable by my LCD panel, Luckily for me my friend Bruce was able to build this circuit for me. Details of this homemade Robodruino Serial output inverter circuit to enable Seetron LCD to be read, are; // Very basic ciruit diagram +5Volts------------------------------<- ---------------------------------<-------------------------------- | | | | | | | | | | | +5Volt | | +5Volts Pin | | | | | | | | | | | {(Emitter)}-----| | | | / | | | / BackPack-Serial in Pin] {BC559Transistor-(Base)}-<[Resistor]-[PrototypeSheild]<[TxPin2]-<-[Robodruino] | | \ | | | |-[4k7ohm Resistor]----{(Collector)} | | | | | | |
|
|
|
|
|