locked
Service or services to control individual servos and read from sensors RRS feed

  • Question

  •  I want an interface board to which I can connect all the basic types of sensors and motors.    for example, I would like to have a board that I can plug in 2 motors, a stepper motor, several IR sensors, sonar, accelerometer, several servos, and some contact sensors.     What would be a good board for that?  Arduino or Make Controller or something else?  Also, when using a board like Make Controller or Arduino, I am wondering if I will have a service for each sensor, and use a manifest to tie it together, or whether I will have one service, with different actions to control each sensor/motor.     Please point me in the right direction.
    Sunday, March 7, 2010 12:50 AM

Answers

  • I am not familiar with the Arduino so I don't know if you can send a command to its serial port that says "Turn on Digital Pin 5". I assume that you cannot do this with the basic board. So what you have to do is write a C program that runs on the Arduino that listens to the serial port for such a command. You have to define your own "protocol" to do this.

    For example, your DSS service might send "DPIN,5,1". This would mean Digital Pin 5, set to value 1 (which is ON). The C program on the Arduino would receive this, set the pin and then send back "OK". If there was some problem, it might send back "ERROR 123". You probably get the idea.

    The trick in all of this is to try to make sure that the Arduino can handle multiple requests and synchronizes with the DSS service properly. That's why it is a "protocol" because it needs some sort of handshaking. Otherwise, if you just send commands and never get a response you have no idea if they worked or not.

    As for reading sensors, you might send "AIN,2" (Analog Input 2) and get back a response "439" which is a value in the range of 0-1023 for a 10-bit analog input.

    Obviously designing and implementing a robust monitor program is not a trivial piece of work. I have given examples using human-readable messages (which is how I prefer to do this) but you can save bytes (and time) using binary. You should also have something like a checksum to make sure that commands are not received that have been corrupted due to noise.

    I hope this is not turning you off trying to use an Arduino. I suspect that other people in the community might be interested too.

    And on a different topic, there are devices called Phidgets that plug into a USB port and provide direct access to sensors, etc. The RDS services for these are currently out of date. I've updated some of them, but I have not had time to post them on CodePlex.

    Trevor

     

    Thursday, March 25, 2010 5:00 AM

All replies

  • There are robot controller boards on the market, such as the Serializer from RoboticsConnection, that do most of what you want.

    How you configure the services is entirely up to you. Personally I prefer to have them all in a single solution. If you are not expecting to be compatible with existing services, e.g. the Generic Differential Drive, then you can define your own services. In our book I experimented with the concept of a Generic Brick. This service could potentially handle a bunch of different analog and digital I/O devices. However, I don't think anyone else has ever used this design.

    Personally, I would go for the simplest possible implementation. For example, if you know that your board has a fixed set of sensors then you can write one service and provide operations to access each of them individually. However, for something like contact sensors there is a Contact Sensor Array contract already defined. This can be an alternate contract on your "brick" if you want. IR, sonar, accelerometer, etc. are generally treated as analog senors. Maybe you should look at the LEGO NXT samples.

    Trevor

     

    Friday, March 19, 2010 2:09 AM
  • Yeah, I found the Serializer from RoboticsConnection, and it seems like it will be the easiest, because it is in C#.    but it is 100 bucks, and and arduino is only like 40 for the same thing, I think.     Perhaps this should be a new thread, but as I will probably try to do it for the arduino, how exactly do you use the C libraries that control arduinos with the C# of Robotics studio?   I have read that you generally use PInvoke to call C functions from C#, but also, there are tutorials about reading directly the serial information from the ports.  I don't want to reinvent the wheel, but I am wondering how to go about it.   PInvoke the C libraries written for arduino, or read the serial information and figure out what it all means.   Which way?
    Friday, March 19, 2010 6:12 PM
  • You  might have a misunderstanding about how RDS works with robots and/or robot controller boards. RDS runs under Windows so you have to have a PC (or an embedded PC on the robot). Assuming you have a desktop PC, you have to set up a communications link between the PC and the robot or controller. This is usually done using a serial port if you don't mind having a cable. In the case of the Arduino, a USB cable can be used because there is a USB to Serial converter on the board. Alternatively, you can connect over Bluetooth if you want a wireless connection. Bluetooth (BT) looks like a virtual serial port, so the programming is the same. There are Arduino boards with BT onboard and that would be my suggestion.

    On the Arduino side, there is a C library that can probably do the serial communications that you need. You will have to write a simple program that I call a "monitor" which allows you to send commands to the Arduino such as "Turn on Digital Pin 5", "Read Analog Pin 2", etc.

    Then you write a DSS service that talks to the serial port on your PC. I have posted a sample Serial Port service here:

    http://www.promrds.com/SerialPort.htm

    Note that this code is just an EXAMPLE of how to use a serial port. I am not suggesting that it is the best way to do it :-) If you look at the various samples that come with RDS you will see a variety of different ways to talk to a serial port.

    Trevor

     

    Tuesday, March 23, 2010 5:34 AM
  • I understand what RDS does, but I supposed it's not clear how the board itself works.    Can you be a little more specific about the "monitor"
    program?   I supposed that the C libraries that come with arduino were to talk to it by the serial port.  But then, why would you even use them if you are reading and writing to and from the serial port anyways with the DSS service.    Can you not do the Turn on Digital Pin 5 thing from the DSS Service over the serial port?   Or is that "monitor" program a one-time thing to program the board to behave in a certain way?   I am sorry for my lack of understanding and I should do more research on programming Arduinos, but I thought it would be irrelevant to learn the C methods to program them if what I wanted to do was Use the CCR and RDS.

    Again, my goal is the have my PC conected by USB to an arduino board.     On the Arduino, I want a couple of motors plugged in, and a couple of sensors plugged in.      That's the hardware.   Then, in RDS, I want to be able to drag a couple of motor services on the screen, and a couple of sensor services (IR, generic analogue, etc).    Now I can do simple program flows, such as connecting sensors to motors, or joysticks to motors, or sensors to dialogue boxes etc.  That's all.    However, I would like to be able to swap out all the various kinds of sensors, like force, light, distance, sonar, etc.        That way the students see that all they have to do is plug in the sensors and motors they need, drag the corresponding boxes onto the Dataflow, and start making simple behaviours.    I need a clear and complete list of steps to accomplish this kind of setup, and I think the list will be very helpful to many people in the future who want to pick up an arduino, plug in a couple sensors and motors, drag the corresponding boxes onto the VPL dataflow, and make simple behaviours.

    Tuesday, March 23, 2010 9:29 AM
  • I am not familiar with the Arduino so I don't know if you can send a command to its serial port that says "Turn on Digital Pin 5". I assume that you cannot do this with the basic board. So what you have to do is write a C program that runs on the Arduino that listens to the serial port for such a command. You have to define your own "protocol" to do this.

    For example, your DSS service might send "DPIN,5,1". This would mean Digital Pin 5, set to value 1 (which is ON). The C program on the Arduino would receive this, set the pin and then send back "OK". If there was some problem, it might send back "ERROR 123". You probably get the idea.

    The trick in all of this is to try to make sure that the Arduino can handle multiple requests and synchronizes with the DSS service properly. That's why it is a "protocol" because it needs some sort of handshaking. Otherwise, if you just send commands and never get a response you have no idea if they worked or not.

    As for reading sensors, you might send "AIN,2" (Analog Input 2) and get back a response "439" which is a value in the range of 0-1023 for a 10-bit analog input.

    Obviously designing and implementing a robust monitor program is not a trivial piece of work. I have given examples using human-readable messages (which is how I prefer to do this) but you can save bytes (and time) using binary. You should also have something like a checksum to make sure that commands are not received that have been corrupted due to noise.

    I hope this is not turning you off trying to use an Arduino. I suspect that other people in the community might be interested too.

    And on a different topic, there are devices called Phidgets that plug into a USB port and provide direct access to sensors, etc. The RDS services for these are currently out of date. I've updated some of them, but I have not had time to post them on CodePlex.

    Trevor

     

    Thursday, March 25, 2010 5:00 AM
  • Thank you for your reply.  I have been doing some research and just today it sorta clicked in my head what you meant by the monitor program and how it would all work, though your ideas on implementation are helpful.   However, the thought of writing the C program and including buffers to receive multiple messages and return responses in a robust, parallel way does seem daunting, since I was specifically trying to avoid that aspect by using RDS.   If I use Arduino, I think I'll have to stick to very simple setups for now.

    However, I also came across the Phidgets and also noticed they were out of date.  PLEASE PLEASE PLEASE make some services that people can use in VPL.   The phidgets seam IDEAL for working with RDS, especially on the beginner level.   I think I could get a lot of people excited about RDS if I could show them a VPL diagram where I just drag some services on and have access to various sensors, servos, and knobs.   This, I believe, is the "endgame" for bridging the gap for the "average" person to want to use RDS and do some robotics.   Kinda like the the Apple II bridged the gap between the serious hobbyists and the masses of average users. (ok, sure, windows 3.1, but still you know what I mean)

     

    Either way, I plan to work with these phidgets, but I'm sure any services I code will not be on par with the stuff you guys at MS do, So again, I believe updating services for RDS-Phidgets would be a worthy endeavor, and much appreciated by the community.

    Thursday, March 25, 2010 8:10 AM