View Full Version : serial communication using c++
Malakili
08-04-2002, 13:03
Vanweric and I are thinking about doing some things with C++ and serial communication so we can control the robot with a laptop outside competition. Anyone know anything about this?
Thanks for the Help.
ALSO: Im new here, im on team 250 with vanweric, ill be around here more often from now on, so now you know who i am :)
First of all, welcome. Can i say that, i've only been here a few monthes. bah, i'll say it anyways. :p
Any way, if you can figure out how to do something with the serial port and C++, i'd love to help, cause i'm learning C++ this year, and so far, i actually got really far. i'm always trying to learn more, and what better way than learning how to play with the actual hardware?
i actually have a family friend that programs palm pilots, and when you make a palm pilot program, you use either C or C++ to create a program to "Hot Sync" the palm pilot and the computer, to download the program to the palm. if you want, i can ask him, cause to go from C to C++ won't be that hard (i hope :D).
another thing we could possibly do, is create a simluator, which will let a laptop or something else emulate the robot controller and operator interface. i'm not sure how either works, beyond the PBASIC code used to program them. i know that many people, including myself, would like to create a simluator, which would make our lives much easier.
so, i'll try to find out about the serial port, and if i can get anything, i'll post it up. although, i can't say if i'll get anything in C++, cause my friend is a C kinda guy. :p
somethnig i just found, although i don't quite understand. you can get it here...
http://www.myspace.d2g.com/first/CD_stuff/serial_1.zip
no, i didn't make it, and i don't quite understand it all. the basic stuff makes sense to me, but don't ask me to explain it to you, cause you'll wind up more confused than i am. :D
Malakili
09-04-2002, 11:28
Thanks,
Are you going to Florida for Nationals? If so we should meet there. Also, ask that friend who programs Palms if he knows anything... post back if you find out anything
well, didn't get a chance to email my friend, i'll try today. have to ask my dad for his email address :p. and yes, i will be at florida. team 810, Mechanical Bulls. the serial class up in my other post doesn't seem to work when i try it, but if anyone else can make it work, try it. we may need to resort to assembly language to make it work, and i don't know that.
Malakili
10-04-2002, 12:49
these look good, im still trying to figure out how to use them though, someone wanna give it a shot?
http://www.marshallsoft.com/wsc4c.htm
Greg McCoy
10-04-2002, 16:26
Are we talking about Visual C++ or Borland C++? Or something else?
well, i'm talking VC++, cause that's what i know. i wasn't aware of a difference between the two, although if there is, i only know VC++.
C++ is C++ regardless of what compiliar you use. The only thing I know Microsoft did in their program that kinda effects the language is they automatically include the boolean header file in all programs. The program I use, Symantec C++ however does not, I need to do a little #include "bool.h" everytime I need to use it.
Greg McCoy
12-04-2002, 12:46
I was thinking that VC++ used different methods to access drivers (like your serial port driver) so that the programs could work through Windows more efficiently. Maybe not...
Unless you can find out how the data is transmitted and processed inside the robot controller, you are SOL... Those team numbers are on there for a reason... it actually sends them...
You could probabaly hook the laptop up to the operator interface and use that as a controller... but as for the laptop emulating the operator interface, that would take some time... Hmmmmm... sounds like a good project. You have me interested now...
well, i've been busy doing lots of C++ work in school. we had to make our own class, that emulated an ATM machine, saved account info, and then transactions. made myself a cool little program, actually had to look somethings up myself, cause i' gettnig too advanced for my teacher. :D
anyways, i haven't had much time to look at the serial port classes. can anyoen who's been doing C++ for a while try looking for some that work? maybe even explain how they work after too? :p
If you have the MSDN Library (it comes with VC++) do a search for "Serial Communications in Win32". It should return a rather lengthy technical article that describes everything you need to do. While it is just plain-'ol C instead of C++, it should work for you.
If you don't have the Library, I can try to find another place with the same info.
i think i have the library, but i didn't install it. maybe i will now. :p
YAY! MY dad's friend, who is a palm programmer, said he'd help me to control the robot through a palm. :p if i can figure that out, a laptop can't be that much harder. :D i'll get back to you with an results.
Fine, you guys got me curious... I'm going to turn this into a personal project...
A project like this could take a while. Innovation FIRST provides no information about the operation of the devices, so you're going to have to reverse-engineer it..
Hey... I may be able to even turn it into my presentation for my Assembly class.
Greg McCoy
18-04-2002, 15:59
Sounds hard...you will have to replicate the entire OI as a Palm program? Sounds like a lot of work, and how are you going to control the robot? The only inputs you can use will be the stylus & buttons, so it seems like driving would be kind of clumsy.
Good luck, just some things I was wondering about :)
Okay... first major setback.
The radio modems and the OI/RC use RS-422 ports. They communicate differently than standard serial RS-232 ports found in your computer. In short, no radio modems unless you figure out a way to work around this problem... I'll research it more... Converters are available to convert it electrically, but it'll cost ya $80.
I don't know if the tether port also uses this method of communication...
well, for controlling it with a palm, after i get that done, i'd be able to do more thnigs with it. have to start somewhere. :D also, could you use the O/I as a go through, and just put everything on one port? you have the 4 analog and 4 digital switches. you can run something on that me thinks.
you have the 4 analog and 4 digital switches. you can run something on that me thinks.
True, but how would you get the data to the joystick port? A joystick uses one pin for each axis and each button. On the standard CH joysticks, thats eight pins. Serial only uses one pin for the actual data. Just something to think about.
Not trying to be a pessimist, but I don't see how the tether could be official RS-232 because it can power the OI. Who knows? Maybe I'm just wrong and it actually is. Only time will tell.
grr, so many problems. we'll find a way though. :D
Originally posted by Ian W.
well, for controlling it with a palm, after i get that done, i'd be able to do more thnigs with it. have to start somewhere. :D also, could you use the O/I as a go through, and just put everything on one port? you have the 4 analog and 4 digital switches. you can run something on that me thinks.
Standard serial port is just recieve/transmit. You'll have to write your own module to take control of the serial port at the hardware level in order to use it as some way to communicate over the other pins through the OI...
I thought you meant turning the entire computer into the operator interface... Hrmm... to me it still seems like a waste to have to go through the operator interface... also it makes the project a whole lot easier...
I'm thinking this isn't the project to jump on. It runs so many potential risks/problems. Someone could use something like this for not-so-good tendencies/revenge during a competition.
how could someone use this during competition? they would immediately be DQ'd if they start using the laptop. of course, i do see your point. why is everything so hard?
Has anyone figured out if the tether is RS-232? I don't have access to any RC/OIs this time of year, so I haven't been able to check.
If it is, you could try writing a quick-and-dirty two-way serial port passthrough/capture program. My idea is to hook the OI and RC up to different serial ports on the computer. The program would then capture everything sent between the two, and forward the packets out the other interface. Doing it that way, the RC/OI would think they are still directly connected.
well, i can try to find out for you in week. but by then, you'll have figured out too. :D
Yeah...I'll slap together a program on my way to nationals. Try it out on a real robot.
hmm, i guess i'll have to come and raid your pit then. :D seems like an interesting project, wish i knew more about C++ (i've only been doing it one year).
Greg McCoy
19-04-2002, 15:43
A more useful project: A full control system emulator. One of these would be handy for testing code out when you don't have the robot handy. Also, a good way to test before downloading to the robot.
If you could make the PWM/Relay outputs so that you could label them (so you know what's going on with the "motors") and visualize their output, while also being able to control the OI, that would be awesome.
Good project for someone with more time and patience then me!
Originally posted by Jnadke
Okay... first major setback.
The radio modems and the OI/RC use RS-422 ports. They communicate differently than standard serial RS-232 ports found in your computer. In short, no radio modems unless you figure out a way to work around this problem... I'll research it more... Converters are available to convert it electrically, but it'll cost ya $80.
I don't know if the tether port also uses this method of communication...
I forgot about that. Another very good point. :)
Dave Flowerday
19-04-2002, 17:23
The tether port does use RS-232. HOWEVER: don't hook a laptop up to this port as +12v from the robot battery is provided on one of the pins. In theory this shouldn't damage anything since RS-232 has a range of -25v to +25v, but I think it would be extremely unwise to try it.
If you're interested in this kind of thing though you should come check out the Wildstang pit and ask an electrical person to show you the Mini Controller we made. We built a little circuit with a microcontroller on it that speaks directly to the robot controller over the tether port. It has a couple of momentary switches on it to retract the hooks and a push button to perform a robot reset. We use it to unhook from the goal after the end of a match rather than carrying out the whole control system onto the field.
VanWEric
30-04-2002, 16:21
If any one can point me in the direction of a good library to play with the serial port, i WILL eventually get this working. as soon as boring summer sets in, i will have nothing but time on my hands. BTW -- this has a very good potential to violate every rule imaginable, but that isnt my goal. I just want to have the ability to break every rule imaginable and feel smug about it.
LOL!!!
Well, if we made something like that, it would make FIRST have to police the control systems/dashboard programs a lot more carefully. it would still be cool to do though, and an emulator for me to test the code without a robot would be godly. :D
Sean Conway
01-05-2002, 15:10
Check out Greenleaf Software, they have a ton of serial comm stuff. I've used 2 of their products, and they both work great.
They're on the web at www.gleaf.com
Matt_Gray
01-05-2002, 15:51
Hey... does anyone know how to write a segment in C++ (if it helps I use the Bourland compiler) to input information from the dashboard output to a communitcations port on the back :confused: :confused: :confused:
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.