large c programming project code examples for microcontrollers needed

Thread Starter

hunterage2000

Joined May 2, 2010
487
Sorry I should of said "complex". I need to see something that constantly monitors a series of failsafe's i.e emergency stop switches while controlling the speed or torque of a DC motor through a varied PWM voltage or current.

I was thinking if this just used a load of if statements that just constantly scanned the inputs to the failsafe switches and the control in an infinite while loop.
 

THE_RB

Joined Feb 11, 2008
5,438
That's a simple project. :)

If you have multiple safety switches, connect them to the same 8bit port. So all port pins are 1 when safe, but any switch activated will make that pin a 0.

Then check the port in one operation;
if(PORTB != 0xFF) // if a switch is tripped!

which is very simple and quick. Obviously if a switch is tripped, you can then do some tests and see which one it was. But the main code only needs that one line to check all switches are safe.
 
Top