|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
using ttl on innovation first
hello every one
im using first 18f8520 with edu code for mplab. im having problams with my code. i want to control my first (connects with rs323 to pc) with hyper tirminal to be precise i want to control my servo on pwm out pins. how i write a code for a thing like that? need yours help please ![]() |
|
#2
|
||||
|
||||
|
Re: using ttl on innovation first
I've never used the EDU controllers before, but I have a fair amount of experience with PICs in general and the IFI FRC controller. Someone else may be able to give you a better answer, but here's what I can tell you:
Under the default code (I downloaded the one available on ifirobotics.com), you can use printf(...) to send stuff out on the serial port. If you want to read in from the serial port, try making the following changes: in ifi_utilities.c: Initialize_Serial_Comms change USART_RX_INT_OFF to USART_RX_INT_ON in user_routines_fast.c:InterruptHanderLow add the following code to the bottom of the function: if (RXINTF) { char data = RCREG; /* data now holds one received character. it should be placed in a buffer somewhere */ } Like I said, I haven't tried this code, but it should work. Post back here if it doesn't, or if you need help writing a receive buffer or anything. You also said "[your] code isn't working," so if you already have some code in the works that's having issues, you might try posting it so we can give you suggestions. Good luck, --Ryan |
|
#3
|
|||
|
|||
|
Re: using ttl on innovation first
thanks rayn,
i post the message it helped me. i have a one more quastion. when i define to control pwm pins what code i need to write to do this things: i mean for example i want when i press on hyper terminal the letter A it will send to pwm out 1 0 like: A= 0; if a press B it will send to pwm out 1 127. B= 127; if a press c it will send to pwm out 1 255. C= 255; if you can help me its great im new in all that ![]() |
|
#4
|
||||
|
||||
|
Re: using ttl on innovation first
Quote:
switch(data) { case 'A': pwm01 = 0; break; case 'B': pwm01 = 127; break; case 'C': pwm01 = 255; break; } A couple of WARNINGS to anyone who wants to start using this code for reading from serial ports:
The usual way to avoid the last problem is to store characters into a global circular buffer in the interrupt handler, then add code outside the interrupt handler (like in Process_Data_From_Local_IO) that checks if there are any new characters in the buffer and processes them accordingly. The advantages of the buffer are:
However, adding a buffer adds a fair bit of complexity to your code, and circular buffers can be easy to mis-code, especially since there's only a vary limited amount of debugging that can be done with the IFI controllers. For examples of how to write such a buffer, try Googling for "circular buffer" or "ring buffer." If you don't feel like investing in the experience of writing your own buffer, allow me (as I'm often apt to do) to point you to the venerable Kevin Watson's implementation of serial port code for the IFI controllers. His code was written for the newer IFI FRC controllers (based off the PIC18F8722 instead of the PIC18F8520 like the EDU controllers), and as such may require some massaging in order to get the hardware portion of the code working, but it still has a good example of a circular buffer, regardless. For the example given of just setting motor values, it should be fine to just put the code given into InterruptHandlerLow because it's not too computationally intensive (just make sure that you control the rate of characters coming to the robot over the serial link. If the rate gets to be several thousand per second or such, you may start encountering problems). As always, if you have any other questions or problems, feel free to post back. Happy coding, --Ryan |
|
#5
|
||||
|
||||
|
Re: using ttl on innovation first
No need to massage any code. Kevin has done remarking and impressive work the PIC controllers from IFI.
All of his EDU Controller Sample code can be found here: (Bottom half of the page) http://kevin.org/frc/2005/ Specifically Serial Driver for the EDU 8520. http://kevin.org/frc/2005/edu_serial_ports_0.3.zip |
|
#6
|
||||
|
||||
|
Re: using ttl on innovation first
Quote:
--Ryan |
|
#7
|
|||
|
|||
|
Re: using ttl on innovation first
thank you very much guy!
you helped me alot especially you rayn. ![]() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Using the TTL port on the RoboVasion (Edubot) Controller | Leav | Programming | 3 | 06-08-2008 11:00 |
| **FIRST EMAIL**/Championship Hotel and Innovation First Information | Katie Reynolds | FIRST E-Mail Blast Archive | 1 | 19-01-2005 16:42 |
| Using the TTL port | Max Lobovsky | Programming | 6 | 25-06-2004 12:44 |
| Innovation First Manual | Cheese Head | Programming | 2 | 19-11-2002 12:44 |
| Innovation First | archiver | 2000 | 0 | 24-06-2002 00:12 |