|
|
View previous topic :: View next topic |
Author |
Message |
borjahuerta
Joined: 08 Mar 2011 Posts: 4
|
18F4580 CAN Bus Potentiometer Send data to siow from RS232 |
Posted: Sat Apr 16, 2011 10:26 am |
|
|
Hello everybody,
I'm trying to program one board "CCS CAN Bus Development Kit". First of all the final object will be, I hope, send information for the rs232. I have a problem because I don't know how can I use the siow to watch if the program are working or not.
This is my code till now, and I think with that code the potentiometer of the A block works ( more or less ) but I can't receive any information in any windows. The steps that I'm doing are:
1- Compile the program
2- Debug the program in the board (all right till this point)
3- Tools<serial port monitor < and appear this message ie_Open Device already open. (and I don't know how can I fix that :(
The program that I'm using is PCWHD.
My code is the following:
Code: |
#include <18f4580.h>
#device ICD=TRUE
#fuses HS,NOPROTECT,NOLVP,NOWDT
#use delay (clock=20000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
#include <can-18F4580.c>
#define GREEN PIN_A5
#define RED PIN_B1
#define YELLOW PIN_B4
#define WRITE_REGISTER_D_ID 0X400 //Destination of the frames (LCD connect with a MCP2510)
void main()
{
int reading,kmH;
setup_port_A(ALL_ANALOG); //port A analog
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(0); //read value at the potentiometer
can_init(); //PIC initialisation
can_putd (0x100,0,0,1,TRUE,FALSE); //departure of the values
delay_ms (1000); //wait until MCP2510 wakes up
while (TRUE) {
reading=read_adc(); //255 samples=>63=1.18V ; 180=3.52V; thx to the fomular:(reading*5V)/255
if (reading<63) {
output_low(GREEN); //for low speed 0<kmH<50 dividing reading/1.28*
output_high(RED);
output_high(YELLOW); }
else if (reading<167) {
output_low(YELLOW); //for indicate average speed 50<kmh<130>180)
{
output_low(RED); //speed to high slow dowm!!! kmH>130*
delay_ms(500);
output_high(RED);
delay_ms(500);
output_high(YELLOW);
}
}
kmH=reading/1.28; //calculate the reading A/D in Kilometer per hour
can_putd(WRITE_REGISTER_D_ID, kmH, 3, 1, TRUE, FALSE); //send value read to node D
printf("nr Speed: %d kmH ", kmH);
}
} |
Thanx 4 all and sorry 4 my english. |
|
|
borjahuerta
Joined: 08 Mar 2011 Posts: 4
|
|
Posted: Sat Apr 16, 2011 11:52 am |
|
|
I didn't want to say send information sorry I wanted to say, see the data. How can I see the data? |
|
|
borjahuerta
Joined: 08 Mar 2011 Posts: 4
|
|
Posted: Sat Apr 16, 2011 12:28 pm |
|
|
maybe is because I have connected the board-rs232 ----> rs232-usb ----> usb-laptop |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Sat Apr 16, 2011 2:17 pm |
|
|
I'd remove the PIC board and just 'loopback' the RS232 pins on the RS232-USB adapter. hint.add a jumper from pin 2<---->pin 3.
Pressing a key on the PC should go out the USB adapter and 'loopback' into the USB port and SIOW should display it onto the screen.
If it doesn't,you've got a problem either in configuring SIOW ,or the adapter or some 'Windows' problem....
Once this is working, then remove the loopback jumper and attach the PIC board.Any data the PIC transmits should be shown on the PC Screen.
hth |
|
|
borjahuerta
Joined: 08 Mar 2011 Posts: 4
|
|
Posted: Sun Apr 17, 2011 5:00 am |
|
|
Thanks a lot HTH, I can't see anything but now the siow works so that its a step lol, somebody know any tutorial how can I programming this board, I need only easy steps cos I need only programming the three potentiometers and send the information by the rs232. So if somebody know any easy totorial please let me know. Greetings.
Borja Huerta |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Sun Apr 17, 2011 5:43 am |
|
|
Doesn't CCS supply you with example programs, either with the kit or in the examples folder of your compiler ?
Instead of trying to get CAN to work, just code the classic 'hello world' into the PIC to verify the PIC,board,cables,etc. work the correctly.
one small step at a time, build on what you learn! |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|