Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   RS232 (Serial) Communication To OI (http://www.chiefdelphi.com/forums/showthread.php?t=58087)

bglass 06-07-2007 22:50

RS232 (Serial) Communication To OI
 
Hey Everybody,

I am working on a project that is not FIRST related, but figured I would come here for help as I am using the IFI Control System (that you all seem to be so good with). I scoured the forums to try to find some answers to my questions, but as it's not legal in the FIRST competitions, couldn't find much of anything.

What I would like to do is essentially emulate the joysticks (and other input devices that plug into the OI) through my laptop. It seems impractical to hook 4 joysticks and other switches up so that I have enough buttons to perform tasks. Unfortunately, my background in programming is primarily in Java. After doing some research, I decided that programming in C would probably allow me more flexibility and be a bit more universal. I don't need to send extremely complex things to the OI, just the values that would normally be sent via the OI (0-254 for the axis, 0 or 1 for the buttons). I read through some forums on Serial Communication in C, but they seemed far more complex than what I need to do for this project. If somebody would be willing to give me the commands to do this, I would appreciate it. I also don't know some of the information that I anticipate that I will need (Baud Rate, etc).

I imagine that this would also be able to help with FIRST during the off-season. It seems there is always a shortage of joysticks, and this would allow for some easy debugging. Look forward to your responses.

Bryan

bear24rw 06-07-2007 23:02

Re: RS232 (Serial) Communication To OI
 
The game ports on the OI (where the joysticks get plugged into) just take digital and analog inputs you could use a microcontroller that interface the digital and analog inputs (i dont remember the name of the device you need to do analog out) but then you could communicate with the micro through serial from a laptop.. might be an easier way (like through the dashboard port) but thats just what i came up with off the top of my head

good luck

lukevanoort 06-07-2007 23:15

Re: RS232 (Serial) Communication To OI
 
Quote:

Originally Posted by bear24rw (Post 634093)
(i dont remember the name of the device you need to do analog out)

I believe Digital Potentiometers (often shortened to didgipots) are what you are referring to.

bglass 06-07-2007 23:40

Re: RS232 (Serial) Communication To OI
 
Looks like the biggest problem with controlling the OI inputs over RS232 from a laptop is that there is only 1 data pin on the serial protocol. I could spend some extra time writing a simulator for the OI and just use an adapter to run the radio straight from my laptop, but that seems like an excessive amount of work. If anybody knows of a simple way to send different values to the different pins on each port of the OI, let me know. I'd still like to do this (even if slightly impractical) because of the flexibility it will allow me. If I'm able to get it working, I'll write a whitepaper and help anybody get the same system up. Appreciate the help.

bear24rw 07-07-2007 00:00

Re: RS232 (Serial) Communication To OI
 
What do you mean there is only 1 data pin? And also writing a simulator for the oi would be close ot impossible since we dont have the code for the OI and also the radio is not rs-232 do DO NOT plug it into your computer. I still think just using a simple micro between your rs232 port and the OI gameport ports is your best bet

bglass 07-07-2007 01:42

Re: RS232 (Serial) Communication To OI
 
Sounds good. Since the consensus seems to be that the microcontroller is the best way to go, I guess I'll have to look into that. If anybody has any suggestions on which to use (or how to get started), please let me know. Best wishes.

Greg Marra 07-07-2007 01:50

Re: RS232 (Serial) Communication To OI
 
Quote:

Originally Posted by bglass (Post 634111)
Sounds good. Since the consensus seems to be that the microcontroller is the best way to go, I guess I'll have to look into that. If anybody has any suggestions on which to use (or how to get started), please let me know. Best wishes.

Having used PIC 18F2455's in an introduction to mechatronics course, I would recommend them. They can be programmed by an inexpensive programmer and support USB communication in addition to RS232. You'll need to use another chip (A MAX232, or similar) to turn the serial from your serial port into the type of serial the PIC likes (there is a voltage difference).

The PIC is programmed in MPLAB, just like the FRC controller. For a bunch of documentation about how to get the PIC to do specific things, I send you to the website of the course I took. It's full of goodies!

But once you can send data to the PIC, you just need to set some digital output pins, some analog output pins, and make them do what the computer says. You could even listen to the feedback LED pins and send them back to the computer for two-way communication.

6600gt 07-07-2007 02:16

Re: RS232 (Serial) Communication To OI
 
1 Attachment(s)
I am working on application that allows you to simulate all four joysticks(2 at any given time) through the program port on the RC. You need to connect the OI to run but thats all. Yes, there will be some interrupt and code overhead but unless you are pushing the processor to the limit it should work for most things. It also has other features. I am concentrating on the DataView and Camera right now but I will work on the Joystick if you require.

The pic and other hardware way is quite possible but also quite messy. PIC, D/A converter, MAX232, code and more code...
Do you know how to access the serial port on the PC using Java?

I have a pic of what it looks like:

bglass 07-07-2007 03:20

Re: RS232 (Serial) Communication To OI
 
Awesome. Thanks for the help everybody. As I have quite a bit of time left on my project, I think I'll probably try both methods (microcontroller and programming port) to see which works better (at least for my purposes). I think I have a pretty good basis (at least for the microcontroller based operation).

As far as the program goes...looks phenomenal so far. Communicating with serial port via Java isn't the most fun thing to do, but I can help you out with it. You're going to need the Java.Comm class (which isn't really hosted anymore). I have a copy that I managed to scrounge up from some of my older programming stuff. Shoot me a message and I'll send it over to you. It's got some decent documentation with it and I should still be able to help you some with it (it's been a while).

Thanks for the help everybody...I knew coming to ChiefDelphi would pay off...

6600gt 07-07-2007 04:04

Re: RS232 (Serial) Communication To OI
 
Quote:

Originally Posted by bglass (Post 634117)
As far as the program goes...looks phenomenal so far. Communicating with serial port via Java isn't the most fun thing to do, but I can help you out with it. You're going to need the Java.Comm class (which isn't really hosted anymore).

Thanks, but I was just wondering. I am using the .NET serialport class so its easy to use.

The DataView(along with the graphing) has been field tested during the 2007 season. It saved my life, especially when I was trying to debug 3 different robots.

I was actually working on a similar project without a computer interface though. Did a lot of research but never put it into practice. I have done a lot of development on the PICs though.


All times are GMT -5. The time now is 00:17.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi