Hello,
I have 2 DC motors and a sensor. I have a NI Daq Card and i have a NI Connector board. I am trying to control DC motor with based on sensor values. Based on the conditions motors should move forward or backward. I am also using motor driver, i already connected my DAQ Card to computer and Connector block and i connected my motors to motor driver and my motor driver to connector block. And i also connected my sensor to connector board.
I gave you a HIGH LOW example which is ritten in PIC BASIC. What i am trying to learn is how i will write in ANSI C and use with DAQ card. And with which function i can read the value of the sensor? Normally if i read port in PIC Basic i will easily read the value.
I checked the DAQ CARD ANSI - C Examples but they aren't too clear. So this i just wanna ask someone who know this.
And to show what i exactly mean, here are some code written in PIC BASIC
INPUT PORTB.0 ; Light Sensor
OUTPUT PORTB.3 ; Left Motor Forward
OUTPUT PORTB.4 ; Left Motor Backward
OUTPUT PORTB.5 ; Right Motor Forward
OUTPUT PORTB.6 ; Right Motor Backward
; to make code easy to read we are defining symbols for our ports:
SYMBOL LSENSOR PORTB.0
SYMBOL LMOTORF PORTB.3
SYMBOL LMOTORB PORTB.4
SYMBOL RMOTORF PORTB.5
SYMBOL RMOTORB PORTB.6
Our functions:
TURN_RIGHT_FORWARD:
HIGH RMOTORF
LOW RMOTORB
LOW LMOTORB
LOW LMOTORF
TURN_LEFT_FORWARD:
HIGH LMOTORF
LOW RMOTORB
LOW LMOTORB
LOW RMOTORF
GO_STRAIGHT_FORWARD:
HIGH LMOTORF
HIGH RMOTORF
LOW LMOTORB
LOW RMOTORB
GO_STRAIGHT_BACKWARD:
HIGH LMOTORB