|
|
Offline
Edison Member
Karma: 15
Posts: 1005
Arduino rocks
|
 |
« Reply #1 on: December 28, 2012, 04:07:43 pm » |
add debugging printouts post exactly the sketch you're using post exactly how you've wired it (plus picture if possible) post exactly what it's supposed to do post exactly what it does instead
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 9
|
 |
« Reply #2 on: December 28, 2012, 07:47:31 pm » |
For now my goal is just to make the wheel's move forward
void setup() {} void loop() { unsigned char buff[6];
buff[0]=0×80; //start byte specific to Pololu motor controller buff[1]=0; //Device type byte specific to this Pololu controller buff[2]=1; //Motor number and direction byte; motor one =00,01 buff[3]=127; //Motor speed “0 to 128″ (ex 100 is 64 in hex)
Serial.write(buff); }
sketch_dec25a:6: error: stray '\' in program sketch_dec25a.cpp: In function 'void loop()': sketch_dec25a:6: error: expected `;' before 'u00d780' sketch_dec25a:11: error: call of overloaded 'write(unsigned char [6])' is ambiguous C:\Program Files\Arduino\hardware\arduino\cores\arduino/HardwareSerial.h:58: note: candidates are: virtual size_t HardwareSerial::write(uint8_t) <near match> C:\Program Files\Arduino\hardware\arduino\cores\arduino/Print.h:49: note: size_t Print::write(const char*) <near match>
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 312
Posts: 35483
Seattle, WA USA
|
 |
« Reply #3 on: December 28, 2012, 07:55:03 pm » |
buff[0]=0×80; //start byte specific to Pololu motor controller That's not an x between the 0 and the 8. I don't know what it is, except that it isn't an x. Serial.write(buff); needs to be: Serial.write(buff, sizeof(buff)); Then, the code compiles.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 9
|
 |
« Reply #4 on: December 28, 2012, 08:41:07 pm » |
She compiles beautifully but i've now encountered a new problem processing.app.SerialException: Serial port 'COM3' already in use. Try quiting any programs that may be using it. at processing.app.Serial.<init>(Serial.java:171) at processing.app.Serial.<init>(Serial.java:77) at processing.app.debug.Uploader.flushSerialBuffer(Uploader.java:77) at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:172) at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:67) at processing.app.Sketch.upload(Sketch.java:1706) at processing.app.Sketch.exportApplet(Sketch.java:1662) at processing.app.Sketch.exportApplet(Sketch.java:1634) at processing.app.Editor$DefaultExportHandler.run(Editor.java:2346) at java.lang.Thread.run(Thread.java:619)
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 312
Posts: 35483
Seattle, WA USA
|
 |
« Reply #5 on: December 29, 2012, 07:53:18 am » |
So, do what the message says.
Do you have any bluetooth devices connected to your computer, or any bluetooth software running?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 9
|
 |
« Reply #6 on: December 29, 2012, 06:10:15 pm » |
I don't believe so ive got a wireless usb stick, mouse and keyboard which there were no conflicts for the first couple of uploads. I tried reinstalling the drivers with no luck I'm stumped.
|
|
|
|
« Last Edit: December 29, 2012, 06:11:47 pm by frostking73 »
|
Logged
|
|
|
|
|
UK
Offline
Tesla Member
Karma: 89
Posts: 6368
-
|
 |
« Reply #7 on: December 29, 2012, 07:11:59 pm » |
Is serial port 'COM3' the right port for your Arduino?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 9
|
 |
« Reply #8 on: December 29, 2012, 08:07:58 pm » |
'Com3' problem solved http://arduino.cc/forum/index.php/topic,25541.0.htmlStill no response from the motor controller though The user manuals mentrions configuring the motor controller by sending a three-byte packet consisting of a start byte, a configuration command byte, and the new configuration byte start byte=0x80 change configuration=0x02 new settings, 0x00-0x7F how would i implement that into void setup() { Serial.begin(9600); } void loop() { unsigned char buff[6];
buff[0]=128; //start byte specific to Pololu motor controller buff[1]=0; //Device type byte specific to this Pololu controller buff[2]=1; //Motor number and direction byte; motor one =00,01 buff[3]=127; //Motor speed “0 to 128? (ex 100 is 64 in hex)
Serial.write(buff, sizeof(buff)); }
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Tesla Member
Karma: 89
Posts: 6368
-
|
 |
« Reply #9 on: December 29, 2012, 08:40:14 pm » |
Pretty much as you have it there, but (1) the byte values that code sends do not match the sequence you described, (2) you could write the byte values as hex literals for clarity, since that's how they're specified (3) the buffer is bigger than needed for that message so you would be sending some uninitialised bytes at the end of the command. You should send the number of bytes in your message, and not the whole buffer if that is bigger. You don't actually need to use the buffer at all - you could just Serial.write((byte)0x80); etc to output each byte in sequence.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 9
|
 |
« Reply #10 on: December 30, 2012, 01:54:03 am » |
Below is my best interpretation of the user guide found below http://www.robotshop.com/PDF/smc05a-low-voltage-dual-serial-motor-controller-guide.pdfI'm kinda hoping that someone could translate the user guide for me as I don't think I'm getting it. void setup() { Serial.begin(9600); pinMode(6,OUTPUT); //hoping this is the pin that will send serial data pinMode(3,OUTPUT); //hoping this is the pin that will reset the motor controller after configuration so that it can receive the four byte command } void loop() { digitalWrite(3,HIGH);
Serial.write((byte)0x80); // start byte Serial.write(2); //config byte Serial.write(2); //new config byte delay(1000); digitalWrite(3,LOW); //after configuration the motor controller must be reset before you can continue using it delay(1000); //The four-byte Motor controller command Serial.write((byte)0x80); //start byte Serial.write((byte)0x00); //device type Serial.write(5); //Motor Number and direction see pic below Serial.write(127); //Motor Speed 0-127 }
|
|
|
|
« Last Edit: December 30, 2012, 10:44:06 am by frostking73 »
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 312
Posts: 35483
Seattle, WA USA
|
 |
« Reply #11 on: December 30, 2012, 07:25:29 am » |
The start byte is 0x80. That is 10000000 in binary. Since none of the data that follows ever has the high bit set, a byte that does have the high bit set defines the start of the command sequence.
The command to change the configuration is 0x02. Why you insist on switching bases is a mystery, but, in this case it doesn't matter.
The third byte defines what the new configuration is to be. The 6th bit of the byte defines the number of motors. You are sending 2 (= 0x02 = 00000010). The 6th bit is 0, which means that you are setting it up to control 2 motors. The remaining 6 bytes define the motor number. The directions regarding the motor number don't make sense to me. If appears that the configuration step applies to 2 motors, in two motor mode, not to a single motor. It also appears as though the numbering convention would allow you to control 32 motors. The driver is not capable of that, so why the protocol supports it is a mystery.
Since the configuration command is always three bytes, it is unclear why you are sending 4 bytes, or what you expect the 4th byte to do.
Are you resetting the controller after sending the config command? Does the appropriate LED blink on the controller?
Why are you sending the config command in loop()?
How is the controller connected to the Arduino? A high res picture is needed.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 9
|
 |
« Reply #12 on: December 30, 2012, 10:53:53 am » |
I made an edit of my previous post to try and explain the four byte command.
Q1. Yes that was my attempt to reset the motor controller after configuration, unfortunately no LEDs are blinking on the controller.
Q2. It was a shot in the dark.
Q3. How it should be and how I've got it
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 312
Posts: 35483
Seattle, WA USA
|
 |
« Reply #13 on: December 30, 2012, 11:06:41 am » |
It's very difficult to tell from that picture if anything is connected to pin 1 of the Arduino. It appears, in fact, that the pin connected to the serial port of the motor controller is connected to pin 5 of the Arduino. That is NOT the pin that Serial talks to.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 9
|
 |
« Reply #14 on: December 30, 2012, 11:53:01 am » |
It most definitely was pin 6 but after your most recent post I changed the pin to 1TX. I also took your advice and transferred the configuration data to set up. No luck on any response from the motor controller though. I've got 4 double A batteries hooked up there reading aprox 5.16v and 48ua if that helps. void setup() { Serial.begin(9600); pinMode(3,OUTPUT); // Three byte Configuration packet Serial.write((byte)0x80); // Start byte Serial.write(2); //Configuration byte Serial.write(2); //New settings comes in three parts //(bits 0-5: motor number)(bit 6: # of motors 1=1 0=2)(bit 7: always 0) // Reset process required in order to allow Four byte motor controller command to follow digitalWrite(3,HIGH); delay(1000); digitalWrite(3,LOW); delay(1000); digitalWrite(3,HIGH); }
void loop() { //Four byte motor controller command Serial.write((byte)0x80); //Start byte Serial.write((byte)0x00); //Device type Serial.write(5);// Motor number and direction comes in three parts //(bit 0: 1=forward 0=reverse) (bits 1-6: motor number) (bit 7:always 0) Serial.write(127);//Motor speed 0-127 }
|
|
|
|
|
Logged
|
|
|
|
|
|