CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

CAN BUS speed read

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
aldina



Joined: 09 Oct 2009
Posts: 26

View user's profile Send private message Send e-mail

CAN BUS speed read
PostPosted: Mon Sep 03, 2018 9:19 am     Reply with quote

I'm using PIC18F2480 and MCP2551 to implement an application that detect speed trucks and select an output according speed. So I need to read speed (km/h) using CAN BUS and then if speed is up to 30 km/h, I use a RED LED ON (C0 port) or if speed is down 30 km/h I use a GREEN LED ON (C1 port).
Can you give me some ideas how can I transfer the speed information and associate to a variable or a AN input. I need to compare it with 30 km/h.
Thank you so much for any help.
Aldina
temtronic



Joined: 01 Jul 2010
Posts: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Sep 03, 2018 3:06 pm     Reply with quote

While I don't use CAN, the process is simple.
Start small, cut code and confirm you can read some of the CAN slave device registers. Once that works, simply read the register(s) that contain the speed. Those must be documented 'somewhere'.
Once that can be done, it's a simple chunk of code to compare what was read (actual speed) to your 'setpoint' of 30KMh. To turn on the LED , it's as easy as if(real_speed >= setpoint ) LED_ON();
Where LED_ON() is a function or macro to control the LED, real_speed is a variable containing the truck's speed, and setpoint is the digital equal to 30KMh.
You'll have to figure out what 30KMh is 'digitally', creat the LED macro, etc.
all easy and simple steps, just take one at a time, get it working, then build from that.

Jay
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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