If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
Arduino to FlowStone test project.
7 posts
• Page 1 of 1
Arduino to FlowStone test project.
Hello,
This is my first "test project" using the Arduino (Uno) together with FlowStone.
I use the A0 line of the Arduino to control the pitch of a sound based on voltage input.
Here is the sketch for the Arduino that sends data from A0 (analog input 0) to Flowstone:
(I use a servo to turn a Sharp GP2D120 IR Range-sensor. The shorter the distance, the higher the pitch. Works great! VERY Stable!)
----------------------------- cut here----------------------------------------
#include <Servo.h>
/*
AnalogReadSerial_turnServo
Reads an analog input on pin 0, prints the result to the serial monitor
(Also sweeps the servo its full arc without using PC processor time.)
This example code is in the public domain.
*/
Servo myservo; //create servo object to control a servo
const int analogInPin = 0; // Analog input pin
void setup() {
myservo.attach(8); // attaches the servo on pin 8 to the servo object
Serial.begin(9600); // start talking
}
int pos = 0; // variable to store the servo position
void readval()
{
byte dummy; // keep in sync
if (Serial.available());
dummy = Serial.read();
int sensorValue = analogRead(analogInPin); // Sharp sensor value
Serial.println(sensorValue*1.0, DEC); // Send raw data (range)
delay(200);
}
void loop()
{
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
readval(); // range?
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
readval(); // range?
}
Serial.println(999, DEC); // flag end of full sweep
}
------------------------------cut here---------------------------
(Using th Arduino to control the servo 'frees up" FlowStone and every full sweep (0 to 180 and 180 to 0) I send out a flag for synchronization.)
Just program the above sketch into the Arduino. Attach the Arduino to the USB port (I use COM:3 at 9600 baud).
Load the FlowStone program and turn on the upper switch, that should do it! (Turn on your PC sound to hear the tones.)
(I use the Com_Port_Tester.fsm FlowStone program as the basis of my very basic FlowStone Arduino "module".)
So far I haven't done much with integer array I store (press the red trigger button to reset the index and clear the array).
This was a fun and highly educational project and I am sure so much more can be done!
This is my first "test project" using the Arduino (Uno) together with FlowStone.
I use the A0 line of the Arduino to control the pitch of a sound based on voltage input.
Here is the sketch for the Arduino that sends data from A0 (analog input 0) to Flowstone:
(I use a servo to turn a Sharp GP2D120 IR Range-sensor. The shorter the distance, the higher the pitch. Works great! VERY Stable!)
----------------------------- cut here----------------------------------------
#include <Servo.h>
/*
AnalogReadSerial_turnServo
Reads an analog input on pin 0, prints the result to the serial monitor
(Also sweeps the servo its full arc without using PC processor time.)
This example code is in the public domain.
*/
Servo myservo; //create servo object to control a servo
const int analogInPin = 0; // Analog input pin
void setup() {
myservo.attach(8); // attaches the servo on pin 8 to the servo object
Serial.begin(9600); // start talking
}
int pos = 0; // variable to store the servo position
void readval()
{
byte dummy; // keep in sync
if (Serial.available());
dummy = Serial.read();
int sensorValue = analogRead(analogInPin); // Sharp sensor value
Serial.println(sensorValue*1.0, DEC); // Send raw data (range)
delay(200);
}
void loop()
{
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
readval(); // range?
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
readval(); // range?
}
Serial.println(999, DEC); // flag end of full sweep
}
------------------------------cut here---------------------------
(Using th Arduino to control the servo 'frees up" FlowStone and every full sweep (0 to 180 and 180 to 0) I send out a flag for synchronization.)
Just program the above sketch into the Arduino. Attach the Arduino to the USB port (I use COM:3 at 9600 baud).
Load the FlowStone program and turn on the upper switch, that should do it! (Turn on your PC sound to hear the tones.)
(I use the Com_Port_Tester.fsm FlowStone program as the basis of my very basic FlowStone Arduino "module".)
So far I haven't done much with integer array I store (press the red trigger button to reset the index and clear the array).
This was a fun and highly educational project and I am sure so much more can be done!
- Attachments
-
- Arduino_Radar_Sound.fsm
- Shorter the range, greater the pitch.
- (95.94 KiB) Downloaded 2087 times
- DSPWill
- Posts: 4
- Joined: Thu Nov 11, 2010 3:46 am
Re: Arduino to FlowStone test project. (and LIDAR)
Hello,
I slightly updated the project so FlowStone receives the data from the Arduino in the form of a string rather than an integer.
This makes it easier (more flexible) in FlowStone to look at the data as a string, float, or an integer depending on what further "processing" you want to do.
(From IRDAR to LIDAR)
Something I want to look at is building a "real" laser range-finder (like at: http://letsmakerobots.com/node/2651) this amazingly simple setup uses a mirror on a reduced speed PC fan and a laser pointer in a most innovative way! I would feed the resulting pulse into an Arduino input (probably a digital input) and use some timing in the Arduino to determine the basic range. Some way-cool DSP of that range data in FlowStone could then produce some amazing (or at least interesting!) results. I would want to mount the range-finder "platform" on a servo for a swept azimuth (and maybe a second servo for elevation information). Getting this all working, with the "shaking" caused by the servo movements could be a real challenge!
(I will also be very careful to protect my eyes, and I would recommend everyone else do the same!)
I slightly updated the project so FlowStone receives the data from the Arduino in the form of a string rather than an integer.
This makes it easier (more flexible) in FlowStone to look at the data as a string, float, or an integer depending on what further "processing" you want to do.
(From IRDAR to LIDAR)
Something I want to look at is building a "real" laser range-finder (like at: http://letsmakerobots.com/node/2651) this amazingly simple setup uses a mirror on a reduced speed PC fan and a laser pointer in a most innovative way! I would feed the resulting pulse into an Arduino input (probably a digital input) and use some timing in the Arduino to determine the basic range. Some way-cool DSP of that range data in FlowStone could then produce some amazing (or at least interesting!) results. I would want to mount the range-finder "platform" on a servo for a swept azimuth (and maybe a second servo for elevation information). Getting this all working, with the "shaking" caused by the servo movements could be a real challenge!
(I will also be very careful to protect my eyes, and I would recommend everyone else do the same!)
- Attachments
-
- ARS2.zip
- (28.21 KiB) Downloaded 1776 times
- DSPWill
- Posts: 4
- Joined: Thu Nov 11, 2010 3:46 am
Re: Arduino to FlowStone test project.
I saw somewhere that someone had hacked the xbox connect and used it as a robotics 3d mapper instead of a laser range finder.
- DSP
- Posts: 150
- Joined: Fri May 14, 2010 10:55 pm
Re: Arduino to FlowStone test project.
Hi guys, I was encouraged by how easily you'll got Arduino and flowstone chatting over the COM port.
I have a Mega which is running a sketch that makes it function with a command language of sorts
I send it strings enclosed in brackets and it parses those and sends back an answer. All seemed good, the COM port shows as connected, Lights blink on the Mega when I trigger the string send, Log says 4 bytes sent for the initialize all command {IA} but I'm not receiving the replying strings and the commands are not getting interpreted and acted on by the Mega. I test in the serial monitor and all is well, I send commands and get replies- I'm about out of things to try.. Any ideas on details I am missing?
Thanks
Quentin
I have a Mega which is running a sketch that makes it function with a command language of sorts
I send it strings enclosed in brackets and it parses those and sends back an answer. All seemed good, the COM port shows as connected, Lights blink on the Mega when I trigger the string send, Log says 4 bytes sent for the initialize all command {IA} but I'm not receiving the replying strings and the commands are not getting interpreted and acted on by the Mega. I test in the serial monitor and all is well, I send commands and get replies- I'm about out of things to try.. Any ideas on details I am missing?
Thanks
Quentin
- Quentin
- Posts: 37
- Joined: Sat Jul 14, 2012 5:35 am
Re: Arduino to FlowStone test project.
It could be down to Termination, how are your incoming strings terminated?
Have you set the incoming termination character on the FlowStone comport module.
OR it could be too fast to see, have you used a queue buffer on the incoming data to capture all of the incoming strings?
Have you set the incoming termination character on the FlowStone comport module.
OR it could be too fast to see, have you used a queue buffer on the incoming data to capture all of the incoming strings?
- DSP
- Posts: 150
- Joined: Fri May 14, 2010 10:55 pm
Re: Arduino to FlowStone test project.
Thanks for your reply- I am sending "commands" to the arduino bracketed {} so I can send the QB command {QB} or ewr{QB}jk and either was the Arduino will parse the command. This is all working at the level of the serial monitor.
I have tried all sorts of ascii line terminators on the flowstone- not sure what to try there or how it would matter- honestly my understanding of serial COM is very basic. Does this mean that you have had successful 2 way COM between an Arduino and Flowstone? I was getting worried when I saw that all the examples were just receiving from, none are sending-to the Arduino.
Thanks
Quentin
I have tried all sorts of ascii line terminators on the flowstone- not sure what to try there or how it would matter- honestly my understanding of serial COM is very basic. Does this mean that you have had successful 2 way COM between an Arduino and Flowstone? I was getting worried when I saw that all the examples were just receiving from, none are sending-to the Arduino.
Thanks
Quentin
- Quentin
- Posts: 37
- Joined: Sat Jul 14, 2012 5:35 am
Re: Arduino to FlowStone test project.
I have 2 way Com between Arduino and Flowstone! It was working all along and indeed it was the lack of line termination from the Arduino resulted in all my headaches.. Serial.print() vs Serial.Println(). Thanks for humoring my frantic requests for help as I figure this stuff out.
Quentin
Quentin
- Quentin
- Posts: 37
- Joined: Sat Jul 14, 2012 5:35 am
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 60 guests