Multitasking

Status
Not open for further replies.
If a bit is 1 in a TRIS register it is an input
If a bit is 0 in a TRIS register it is an output
The value or state of output pins are set by the LAT register

Example
TRISB=0b11110000 // 0xF0
LATB =0b10101010 // 0xAA

on the pic pins
bit 0 will be 0
bit 1 will be 1
bit 2 will be 0
bit 3 will be 1
bits 4-7 are inputs and do not have any voltage on them. To the outside world the are tri-stated.

You have done well with the info provided here but we need to get you to start reading manuals, tutorials, and datasheets. That is unless this is your one and only project.
 
of course this is not my only project, there are multiple tricks to do, like this afternoon I modified the source code, tommorow I will post and now I can understand a little bit about the time slot thingy. I made the throttle flashing rate different to steering, so I can program both of them conviniently.

Tommorow I will post something. Thanks 3v0 for ur clear explanation!!!
 
Code:
iPulse2 = GetPulse2();
		
if (iPulse2 < 7000)                 /*If iPulse2 is less than 1.4ms*/
{
	vForward();
	tState = 1;
}
	
if (iPulse2 > 8000 && tState == 1)                 /*If iPulse2 is more than 1.6ms*/
{
	vBrake();
	tState = 2;
}

from this code I get the correct braking signal, but I don't have any idea how to make my microcontroller remember how to differentiate Brake and Reverse.

In order:
1. Standby
2. Forward > Brake, after this, could be Forward OR Reverse.

1. Standby
2. Brake > Reverse, after this could be Forward OR Reverse.

The KEY is before Reverse, Brake must came into play while Forward is open for any time.

What should I do? Thanks!
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…