Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC18F2431 PCPWM module

Status
Not open for further replies.
The main ( pressing ) issue is the interrupt..... You cant set the ADC to start conversion on the index input AND use the same interrupt to read the ADC.... It'll never be ready... When it boots it takes sooooooo long to restart the ADC conversion.... If the ADC is on continuous why don't you use the ADIF to interrupt??
 
The main ( pressing ) issue is the interrupt..... You cant set the ADC to start conversion on the index input AND use the same interrupt to read the ADC.... It'll never be ready... When it boots it takes sooooooo long to restart the ADC conversion.... If the ADC is on continuous why don't you use the ADIF to interrupt??
If I put 'xx1xx' on ADCON3<4:0> it says: "Input Capture 1 (IC1) starts A/D sequence". The datasheet specifies that in this case the GODONE bit will be set and cleared by hardware. So doesn't that mean that I don't need an AD interrupt and that input capture 1 interrupt will do all the work?

One other thing!!! You are using AVDD and AVSS for the ADC reference but you haven't connected them... The warning is telling you that Vref+ is at 0v..
I set ADCON1 <7:6> to 00: That says: "VREF+ = AVDD, VREF- = AVSS, (AN2 and AN3 are Analog inputs or Digital I/O)". Doesn't that mean I will have +5V and 0V as reference?(VSS and VDD of the PIC which are not showed in proteus for simplicity)?
 
The motor starts but accelerates and decelerates very slow. It does respect the position of the pot(meaning it's speed varies with the it's position) but the speed modifies very very slow even if the duty cycle is 100% and even if from 100% I drop it down to 0% it decelerates very very slow :(
 
Last edited:
*Even if I manually set the dch and dcl to 0 in the code the motor still runs slow and yet modifies it's speed along with the pot's location...that is beyond me.
 
I swapped OVDCOND and OVDCONS registers and it now goes bananas
If you do that the duty cycle will have no influence on the PWM modules and the motor will run at full speed. It's basically what we did first to check if the module was configured correctly.
 
Yeah I figured as much..... My problem here is I'm running PNP ~ NPN so I'm inverting the output..

I have now swapped it all to NPN and 5v.... I can get it running quite fast, but it doesn't seem to correspond to the ADC input!!!
 
Yeah I figured as much..... My problem here is I'm running PNP ~ NPN so I'm inverting the output..

I have now swapped it all to NPN and 5v.... I can get it running quite fast, but it doesn't seem to correspond to the ADC input!!!
Are you using the ADC interrupt feauture? Because if so it must be specified in the ADCON3 that triggers are disabled(if you haven't already done that that is)
 
Right!!! If I set dch to 255 the motor spins very fast.... The PDCx pairs require a 14 bit number .. If we set dch to 00111111b then problems... If I set dch to 11111111b then the motor spins... This is because the PDCx value is bigger and the PWM is set to permanent 1.... I think that the PDCx pairs are out of sequence...
 
Right!!! If I set dch to 255 the motor spins very fast.... The PDCx pairs require a 14 bit number .. If we set dch to 00111111b then problems... If I set dch to 11111111b then the motor spins... This is because the PDCx value is bigger and the PWM is set to permanent 1.... I think that the PDCx pairs are out of sequence...
Did you get it to spin respecting the pot position?



Also the datasheets specifies:
"The upper 12 bits of PDCn hold the actual duty cycle value from PTMRH/L<11:0>, while the lower 2 bits control which internal Q-clock the duty cycle match occurs.". I didn't completely understand what these two bits actually do(to my understanding they allow for a finer resolution of the PWM signal) but the way I set it up they will always stay on 00(for which: "duty cycle match occurs on Q1").
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top