![]() |
EduBot and USART ports
The 2004 Edubot includes two serial ports (USART): USART1 is the programming port which has voltage conversion for interfacing with an RS-232 port, and USART2 is the TTL port on the Edubot. No dedicated handshaking line is available on the TTL port, although Innovation FIRST states that any of the digital I/O pins could be used for this purpose.
Has anyone succeeded in modifying the code to make use of the TTL USART2 port? I have a USART compatible sensor, but am just beginning to learn C and the Microchip 18F8520. I miss the days of just hooking up a pot or analog sensor (gyro) and being able to read the value of a byte directly. Mechanical engineers get spooked around all this programming/computer science stuff. Your help is appreciated. Dave... |
Re: EduBot and USART ports
Quote:
If u need some code i can do that. I can give you some code i wrote to read these sensors. |
Re: EduBot and USART ports
Quote:
|
Re: EduBot and USART ports
Quote:
|
Re: EduBot and USART ports
I am also interested in using the TTL port on the EDUBOT to communicate with another micorprocessor. If anyone has some code to do this I would really appreciate seeing a copy.
Don Taylor Team 343 Metal-in-Motion |
Re: EduBot and USART ports
Quote:
|
Re: EduBot and USART ports
Quote:
The ini_aliases.h header file has the following line: #define usart2_RX PORTGbits.PORTG2However, whenever I try to build the project with "usart2_RX" in my user code, I receive the following error: Executing: "c:\mcc18\bin\mcc18.exe" -p=18F8520 "user_routines.c" -fo="user_routines.o" /i"C:\mcc18\h" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-Does anyone know what "unknown member" or "__tag_43" means and how I can resolve this issue? |
Re: EduBot and USART ports
Let me appologize for not posting this when i said i would. This stuff was on my MP3 player, which i lost the cable to and just found.
anyway here ya go: PHP Code:
Quote:
http://www.microchip.com/download/to...b18/51297b.pdf there is also 2 really good whitepapers on using the USART in asyncronous mode at the assembly level: http://www.microchip.com/download/ap...c16/00774a.pdf http://www.microchip.com/download/li...oots/usart.pdf |
Re: EduBot and USART ports
Quote:
Thanks for the info, but it brings a few more questions. You've obviously used this code with the Edubot since you have references to "ifi_..." and "rc_dig...". Where exactly does this code belong? Do I copy it to the user_routines.c file or somewhere else? Also, you use the include directive for "sensors.h" but this doesn't seem to be in one of the directories with the Edubot sourcecode or /mcc18/h folder. If this is a separate header file, can you please post it as well? The digital compass we are trying to use sends three bytes through the USART. Will these correspond to sensors[1], sensors[2] and sensors[3] directly, or is this just a coincidence? Your help is appreciated. |
Re: EduBot and USART ports
Quote:
PHP Code:
I will give a breif description of how this code works: First let me explain exactly how this code works. We actually have 3 sensors multiplexed to the serial port through some buffer ICs, which are controlled by digital outs 14-16. The output from these three sensors are stored in sensors[1] sensors[2] and sensors[3]. The distance sensors we are using send a 3 byte packet. The 1st byte is always 01010101 the reamaining 2 bytes are ASCII characters, which contain the distance in cm. The first important thing this code does it to configure the buffers i described above. The majority of the code is in a loop, which runs three times. The first time it reads the first sensor, the second time the second sensor... since you are only using one sensor you can kill the whole loop thing as well as the buffer code. Next the serial port is configured: PHP Code:
PHP Code:
since the first byte is always 01010101 we can look for that: PHP Code:
I hope this makes even the slightest inkling of sense. If it does i am glad i was able to help. O am always happy to answer questions. |
Re: EduBot and USART ports
Quote:
This actually makes quite a bit of sense. Even though we have only have one sensor, it too sends three bytes in a row. If the digital compass has a clk, it will send data in sync with the clk signal. If we tell it to operate in conitunous mode, it sends the three bytes and then waits 480ms before sending the next packet. I'll try adding the sensors.h file to our workspace. Dave... |
Re: EduBot and USART ports
Quote:
Code:
extern volatile near union {Code:
#define usart2_RX PORTGbits.RG2Code:
#define usart2_RX PORTGbits.RX2which is the receive port for USART 2. The error just doesn't show up if you don't use usart2_RX because the preprocessor doesn't insert PORTGbits.PORTG2 anywhere in the code and the compiler never sees it. |
Re: EduBot and USART ports
Quote:
|
Question and Re: EduBot and USART ports
First, thanks to all that have posted to this thread, it has helped us greatly. We are still having one problem though. Our code works great on the EDU Bot controller but will not work on our Robot Controller. We have looked at the signals with a scope and think there might be something wrong with our controller(it appears there is something driving the line from the controller). Our question is this! Is there any differences in using the TTL port on the EDU Bot controller and the Robot Controller? :confused:
|
| All times are GMT -5. The time now is 00:33. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi