hi
first you need to clarify following things
1) whether increase in temperature has any relation with speed of stepper motor (i.e if temperature increase speed increase or vise versa), or your stepper motor has fixed
speed.
2) half step or full step configuration or any other config
3) how precise you temperature need
depending on that you can start writing code.
few steps to start i will suggest below
Code:
#include<header_file_of_mcu.h
main()
{
initialise_adc(); // init your adc channel here
initialise_stepper motor(); // init port to interface stepper motor
initialise_timer(); // init your timer for 5 ms say for adc scanning depend upon scan rate
initialise_timer1(); // init your some other timer for pwm to drive motor
while(1)
{
}
}
//this should be your general structure
- - - Updated - - -
for driving simple stepper motor you can try this for initial trials
1. CMCON = 0x07; // To turn off comparators
2. turn off analog to digital converters for that port you wanted to interface stepper motor so they will work as digital I/O
3. make that PORT as output port
4. send full wave sequence PORT_to be used = 0b00000011;
5. then some delay Delay_ms(500);
6. PORT_to be used = 0b00000110;
7. Delay_ms(500);
8. PORT_to be used = 0b00001100;
9. Delay_ms(500);
10. PORT_to be used = 0b00001001;
11. Delay_ms(500);
keep this sequense (from 4- 11) in while loop
but using delay is not at all good practice , telling you this steps to initially atleast making stepper motor work , you can do this via using timer as PWM or using timer inturrupt .
for ADC you need to have proper circuit like which temperature sensor your using ? whats sampling rate etc.
if you provide complete detail it will be helpfull.