Offline
Newbie
Karma: 0
Posts: 24
|
 |
« Reply #15 on: October 30, 2012, 04:42:41 pm » |
I think that asking a lot. I just want to do something other than simple LEDs and a potentiometer/servo code. Excuse me.
|
|
|
|
|
Logged
|
|
|
|
|
USA, FL
Online
God Member
Karma: 11
Posts: 571
A life? Where can I download one of those?
|
 |
« Reply #16 on: October 30, 2012, 06:52:18 pm » |
Change Messenger message; To this CmdMessenger message; They are telling you it's called CmdMessenger not just Messenger..
|
|
|
|
|
Logged
|
//LiNK
|
|
|
|
UK
Offline
Faraday Member
Karma: 15
Posts: 2852
Gorm deficient
|
 |
« Reply #17 on: October 31, 2012, 08:21:10 am » |
So, there is a list of candidate constructors. Pick the one that matches your requirements.
|
|
|
|
|
Logged
|
Per Arduino ad Astra
|
|
|
|
USA, FL
Online
God Member
Karma: 11
Posts: 571
A life? Where can I download one of those?
|
 |
« Reply #18 on: October 31, 2012, 08:38:33 am » |
I had a look at this and I must say, it baffles me (which is easily done). For one the example code that website gives is full of errors. I have attempted to fix the errors but was unsuccessful on some of them (trust me, there was a ton). This is the code that I came up with: #include <Messenger.h> #include <Servo.h>
#Define SPEED_SERVO_PIN = 2 #Define SPEED_SERVO_0_US = 2800 #Define SPEED_SERVO_200_US = 870
Servo hand; Messenger message;
sendVersion void() { Serial.Println(F ("AD ArduDash 01.12")); }
Sendok void() { Serial.Println(F ("OK")); }
sendError void() { Serial.Println(F ("ERROR")); }
setSpeedServo void(int speed) { int microseconds = map (speed, 0, 200, SPEED_SERVO_0_US, SPEED_SERVO_200_US); hand.writeMicroseconds (microseconds); }
setSpeed void() { int speed = message.readInt (); if (speed <0 | | speed> 230) { sendError(); return; } setSpeedServo(speed); Sendok(); }
void OnMessage() { switch(message.readChar()) { case 'V': sendVersion(); break; case 'S': setSpeed(); break; default: sendError(); break; } }
serialEvent void() { message.process(Serial.read()); }
void setup() { hand.attach (2); Serial.Begin (19200); message.attach(OnMessage);
setSpeedServo(0); }
void loop () { }
It is "Messenger" according to the library and the example code. Messenger message; But can't get it to compile myself. If someone that has more knowledge on libraries could look at it, they could tell you more. Here's the compile errors: sketch_oct31a.ino:4:2: error: invalid preprocessing directive #Define sketch_oct31a.ino:5:2: error: invalid preprocessing directive #Define sketch_oct31a.ino:6:2: error: invalid preprocessing directive #Define sketch_oct31a:9: error: expected constructor, destructor, or type conversion before 'void' sketch_oct31a:10: error: expected constructor, destructor, or type conversion before 'void' sketch_oct31a:11: error: expected constructor, destructor, or type conversion before 'void' sketch_oct31a:12: error: expected constructor, destructor, or type conversion before 'void' sketch_oct31a:13: error: expected constructor, destructor, or type conversion before 'void' sketch_oct31a:15: error: expected constructor, destructor, or type conversion before 'void' sketch_oct31a:2: error: 'Messenger' does not name a type sketch_oct31a:4: error: expected constructor, destructor, or type conversion before 'void'
|
|
|
|
|
Logged
|
//LiNK
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
|
 |
« Reply #19 on: October 31, 2012, 08:54:44 am » |
First, it's #define, not #Define. That will get rid of the 1st three error messages.
Second, you have the function name in front of the type. That's completely backwards. There goes the next 6 messages.
Third, Messenger is obsolete. CmdMessenger replaces it. Trying to modify examples for obsolete classes is a waste of time. Doing so when you don't know what you are doing is even more so.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 11
Posts: 393
|
 |
« Reply #20 on: October 31, 2012, 09:08:56 am » |
#Define SPEED_SERVO_PIN = 2 #Define SPEED_SERVO_0_US = 2800 #Define SPEED_SERVO_200_US = 870
Also, there is no equals sign in a #define directive. What these should be is: #define SPEED_SERVO_PIN 2 #define SPEED_SERVO_0_US 2800 #define SPEED_SERVO_200_US 870 Another common mistake is for people to put a semicolon at the end of the #define directive, like this: #define SPEED_SERVO_PIN 2; // <-- don't do this! Not that you've done that here, but just to aware of another common mistake. Some people prefer to replace #define preprocessor directives with static const int SPEED_SERVO_PIN = 2; which is actually a compiler statement, and allows for more rigorous type checking. It accomplishes much the same thing in most common contexts.
|
|
|
|
|
Logged
|
|
|
|
|
USA, FL
Online
God Member
Karma: 11
Posts: 571
A life? Where can I download one of those?
|
 |
« Reply #21 on: October 31, 2012, 11:46:23 am » |
First, it's #define, not #Define. That will get rid of the 1st three error messages.
I am shaking my head that I did not catch that.. Second, you have the function name in front of the type. That's completely backwards. There goes the next 6 messages.
That's what I get for not being experienced.. Third, Messenger is obsolete. CmdMessenger replaces it. Trying to modify examples for obsolete classes is a waste of time. Doing so when you don't know what you are doing is even more so.
From the tutorial he was following, they were using Messenger. It looked like the tutorial was pretty old, so I downloaded that library and installed it. The example has: Messenger message; I have written it many different ways and still get the error.. @Pico I knew there wasn't supposed to be an equals sign, but was trying to get the error to go away and I was grasping at straws.. It never even crossed my mind about the capitol "D"
|
|
|
|
« Last Edit: October 31, 2012, 11:49:23 am by codlink »
|
Logged
|
//LiNK
|
|
|
|
USA, FL
Online
God Member
Karma: 11
Posts: 571
A life? Where can I download one of those?
|
 |
« Reply #22 on: October 31, 2012, 12:00:46 pm » |
Thanks to Paul and Pico, I got it to compile. Tommy, if your still around try this code: #include <Messenger.h> #include <Servo.h>
#define SPEED_SERVO_PIN 2 #define SPEED_SERVO_0_US 2800 #define SPEED_SERVO_200_US 870
Servo hand; Messenger message;
void sendVersion() { Serial.println(F ("AD ArduDash 01.12")); }
void Sendok() { Serial.println(F ("OK")); }
void sendError() { Serial.println(F ("ERROR")); }
void setSpeedServo(int speed) { int microseconds = map (speed, 0, 200, SPEED_SERVO_0_US, SPEED_SERVO_200_US); hand.writeMicroseconds (microseconds); }
void setSpeed() { int speed = message.readInt (); if (speed <0 || speed> 230) { sendError(); return; } setSpeedServo(speed); Sendok(); }
void OnMessage() { switch(message.readChar()) { case 'V': sendVersion(); break; case 'S': setSpeed(); break; default: sendError(); break; } }
void serialEvent() { message.process(Serial.read()); }
void setup() { hand.attach (2); Serial.begin(19200); message.attach(OnMessage);
setSpeedServo(0); }
void loop () { }
|
|
|
|
|
Logged
|
//LiNK
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 24
|
 |
« Reply #23 on: November 01, 2012, 05:05:26 am » |
|
|
|
|
« Last Edit: November 01, 2012, 05:37:06 am by tommy27 »
|
Logged
|
|
|
|
|
USA, FL
Online
God Member
Karma: 11
Posts: 571
A life? Where can I download one of those?
|
 |
« Reply #24 on: November 01, 2012, 05:23:33 am » |
Nice vid Tommy!
You could always give it a shot!
|
|
|
|
|
Logged
|
//LiNK
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 24
|
 |
« Reply #25 on: November 01, 2012, 05:36:02 am » |
Can I export rpm data for an other servo with python?
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
|
 |
« Reply #26 on: November 01, 2012, 05:38:24 am » |
Can I export rpm data for an other servo with python? This question does not make sense. RPM is a measure of speed. How can python, on the PC, know how fast something connected to the Arduino is turning?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 136
Posts: 19000
I don't think you connected the grounds, Dave.
|
 |
« Reply #27 on: November 01, 2012, 05:40:58 am » |
This question does not make sense. It does, if you watch the video 
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
|
 |
« Reply #28 on: November 01, 2012, 05:46:23 am » |
It does, if you watch the video I watched the video. It still doesn't. The context in which it might make sense is missing. The python script and the Arduino code, to be specific.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 24
|
 |
« Reply #29 on: November 01, 2012, 05:49:59 am » |
Can i change this code for rpm data??? import time import pyinsim import serial
ARDUINO_PORT = 'com3:'
arduino = serial.Serial(ARDUINO_PORT, 19200, timeout=1) time.sleep(3)
def outgauge_packet(outgauge, packet): speed_kmh = int(packet.Speed*3.6) speed_command = 'S {0}\r'.format(speed_kmh) arduino.write(speed_command) arduino.flushInput()
outgauge = pyinsim.outgauge('127.0.0.1', 30000, outgauge_packet, 30.0)
pyinsim.run()
|
|
|
|
|
Logged
|
|
|
|
|
|