Let us speak about the connection of the encoders.How do you intend registering them in the micro, have you considered the T1CKI to use TMR1 as a counter?
Max.
But encoder rated 10V DC-24V DC and I can convert it into 5V DcYou will need to use 5v for the encoder supply.
Max.
I think I should try by writing codeI believe yours is RS422 if so it is 5vTTL to 30v supply.
It shows 5v to 30v in your PHOTO!.
Max.
int Count = 0;
void main (void)
{
T1CON = 0b00000001;
while (1)
{
while (! TMR1IF);
TMR1IF = 0;
Count ++;
if (Count == 32000)
{
Count = 0;
}
}
}
It may catch the eye better for someone familiar with C, using the TMR1 as a counter etc.Note : should I start new thread ? because it's suitable for Embedded system forum
I want to count 32000 PulsesI would not use TMR1 the way you are using it. When the object is detected I would load TMR1 with it's overflow value (65536 decimal 10000 hex) minus the count you want. It will then generate an interrupt when it overflows so the interrupt service routine can trigger the air jet.
Les.
something like thisLooks about right to me.
Max.
void main()
{
TMR1H=0x8300; // initial count values in timer1 register
TMR1L=0x00;
TMR1IE=1; //Enable timer interrupt bit in PIE1 register
GIE=1; //Enable Global Interrupt
PEIE=1; //Enable the Peripheral Interrupt
TMR1ON = 1; //Start Timer1
}
void interrupt timer_isr()
{
}
I am using TMR1 to count pulses on pin RC0. Timer1 is just a 16 bit counter it can count up to 65535 (16 bits) andI don't program in C, but wouldn't the TMR1H= 83 ?
Max.
I don't program in C, but wouldn't the TMR1H= 83 ?
Max.
I just used online converter that gives 8300I want to count 32000 Pulses
65536-32000= 33536 = 0x8300
TMR1H=0x8300; // initial count values in timer1 register
TMR1L=0x00;
void main()
{
TMR1H=0x82; // initial count values in timer1 register
TMR1L=0xff;
TMR1IE=1; //Enable timer interrupt bit in PIE1 register
GIE=1; //Enable Global Interrupt
PEIE=1; //Enable the Peripheral Interrupt
TMR1ON = 1; //Start Timer1
}
void interrupt timer_isr()
{
// code to trigger the air jet //
}
