Support

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 Demo

Post any examples or modules that you want to share here

Arduino Demo

Postby MyCo » Wed Oct 24, 2012 12:22 am

Hi,

Here is a demo for interfacing an Arduino Uno.

FlowStoneDemo.jpg
FlowStoneDemo.jpg (98.87 KiB) Viewed 36973 times


I've attached the FlowStone Schematic and the Arduino Sketch.

Here are the details:
This Demo communicates over the serial port, which the Arduino provides over USB. The Protocol runs at 115200 Baud, and is in a raw chunk format. That means, the data is not plain text, and it can transfere anything. The maximum Chunk size is 64Byte, which is the buffer size of the Arduino Hardware Serial Implementation.
The demo demonstrates a polling system, so the Flowstone Schematic as to ask the Arduino, for data. It's not event driven. At the moment there are only 5 commands, that the Arduino-Sketch can Handle:
0x11 HELLO - Just to test if the Sketch is running
0x22 PIN_MODE - Set the Direction of all Pins
0x33 DIGITAL_OUT - Output LOW/HIGH on the Pins that are configured as Outputs
0x44 DIGITAL_IN - Read LOW/HIGH from Pins that are configured as Inputs
0x55 ANALOG_IN - Read 8-Bit ADC values from Pins that are configured as Analog Input

The protocol is very simple to extend. It also supports Error-Reporting, and the FlowStone-Schematic automatically cancels the communication when an error occured.

Some Notices: On this Demo I excluded the pins 0&1, the reason is: These pins are used for the serial communication, changing these would kill the communication with the PC.
On Pin 13 is a yellow LED, that you can toggle. But on some versions, this pin is connected directly. That means there is always a pull down on this pin, and you can't use it as general I/O. You have to be careful with this pin (drive it with enough current when it is an Input, pull less current, when it's an Output)

Have fun,
Maik
Attachments
FlowStoneDemo.zip
(130.18 KiB) Downloaded 2112 times
User avatar
MyCo
 
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany

Re: Arduino Demo

Postby acg2010 » Fri Oct 26, 2012 2:54 am

MyCo - very cool project, can't wait to hook up my arduino and play around with it.

MyCo wrote: On Pin 13 is a yellow LED, that you can toggle.


Not sure but it appears you left out the yellow LED but easily remedied by just adding one from the tool kit and it flashes on and off once you start the timer.
acg2010
 
Posts: 80
Joined: Tue Oct 05, 2010 3:18 am

Re: Arduino Demo

Postby MyCo » Fri Oct 26, 2012 4:28 am

No, I mean, the LED is on the Arduino-Board. On some newer versions, they use an Opamp buffer to drive it. On older versions and on the current "Uno SMD Edition" it is directly connected to the port pin. So this can make trouble, if you don't know that.
User avatar
MyCo
 
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany

Re: Arduino Demo

Postby acg2010 » Fri Oct 26, 2012 5:24 am

Ooops, my bad, I misunderstood you because my actual Arduino Uno did not have a yellow LED, I should have read your post closer.
acg2010
 
Posts: 80
Joined: Tue Oct 05, 2010 3:18 am

Re: Arduino Demo

Postby ahcurer » Sun May 05, 2013 6:12 pm

@MyCo,
Why are you shifting the analog read right 2 bits in the sketch? The Arduino chip (Atmega8, Atmega168, Atmega328, or Atmega1280) all use 10 bit A/D's. I got this to work for my UNO by commenting the shr 2 out... Then in the schematic changing the div by 255 to div by 1. Right?
Nice kit BTW.
ahcurer
 
Posts: 7
Joined: Sat Jun 23, 2012 1:55 am

Re: Arduino Demo

Postby MyCo » Sun May 05, 2013 8:48 pm

The ADC is read in the 10Bit Mode by default in the Arduino core functions. But you'll notice in 10Bit mode, the 2 Lowest bits are just noise. This is because, there is not enough decoupling and filtering on the ADC-Pins and the ADC-Ref. Also the Arduino core uses the supply voltage as reference, which is the worst Reference that you can use. This means, you can't measure anything near the right values. This is one reason for using only 8Bit: just because it doesn't matter, the values are close enough.

Another reason for using only 8Bit is the data transfer. Serial data transfer is very slow so every Byte that hasn't to be send out to the PC saves time.

What you've done for using 10Bits shouldn't work. The reason for that is: you can't send a 10Bit value in 1 Byte. You'll notice that the next line after the right shift, is:
Code: Select all
chk[pin] = (uint8_t)val;


Which says, only use the lowest 8Bit from "val" and store it in the data chunk. So no matter what you put into val, it get's always truncated to 8 bit. By removing the shift right, you'll just send the lowest 8 Bit of the 10Bit ADC value to the PC.
The change to the "div by 255" isn't correct either. Let's say you have correctly send the 10 Bit to the PC and received that correctly, then the "div by 255" should be changed to "div by 1024".

To make the whole project work with 10Bit ADC, you'll have to change the protocoll and this means you'll have to change the Sketch section under "case COMMAND_ANALOG_IN:" to send twice as much data. And also in the FS Schematic, you have to read twice as much data.

It is not impossible, but trust me, the results won't be that good. So it's not worth the trouble.
User avatar
MyCo
 
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany

Re: Arduino Demo

Postby ahcurer » Sun May 05, 2013 10:48 pm

Thanks MyCo, I started to remove the type cast to uint8_t to use uint16_t and noticed that I would have to change everything.
Then I read your reply, I figure it's no big deal adding extra bytes to the serial data stream as this thing is not "mission critical" and an update every 500ms would be no big deal to me for my work, fast as possible would be best though. And yes, it worked for me only because the raw analog value of my temp probe was 145, (less than 255) so I mis-lead myself thinking it was ok. I will try something else without the last two bits.
I see now what you mean and thanks for the reply.
Thanks for this project.
ahcurer
 
Posts: 7
Joined: Sat Jun 23, 2012 1:55 am

Re: Arduino Demo

Postby poorichguy » Wed May 29, 2013 4:46 am

MyCo

Thanks for this great project. If I wanted to setup my arduino with a proximity sensor that required some other code setup, how would I do this and have it send the results into flowstone?

Thanks
poorichguy
 
Posts: 1
Joined: Wed May 29, 2013 4:43 am

Re: Arduino Demo

Postby micoze » Mon Jan 20, 2014 4:36 am

Hi MyCo or and any one hoe can help,

I am new in programming and I found your schema incredibly good to use with FL studio 11.

So I would like to use it wirelessly with a pair of xBee ,I used The X-CTU to programmed themes .
so I set everything up and I know I transmited the signal as I tryed it on the terminal .

ok so Com 4 : arduino uno
and Com 6: usb serial port
So when I open with the Com 4 it work perfectly
But when I try to open with the Com 6 ,it doesn't open it .
What is wrong ?
How come it doesn't open usb serial port?
Your help will be the most welcome
micoze
 
Posts: 4
Joined: Mon Jan 20, 2014 3:27 am

Re: Arduino Demo

Postby MyCo » Mon Jan 20, 2014 4:05 pm

Maybe the port is used by another program. Just a guess, don't really understand what you're trying.
User avatar
MyCo
 
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany

Next

Return to User Examples

Who is online

Users browsing this forum: No registered users and 20 guests