Author Topic: PIC16F1847 PWM output need pull up / down resistor  (Read 2102 times)

0 Members and 1 Guest are viewing this topic.

Offline VekettiTopic starter

  • Regular Contributor
  • *
  • Posts: 232
  • Country: fi
PIC16F1847 PWM output need pull up / down resistor
« on: August 14, 2023, 04:41:17 pm »
Dear All,

I know this might sound stupid but I'm about to use PIC 16F1847 to control RC digital servo and using the PWM CCP1 output. As I'm using the standard CCP1 and not enchanced CCP I didn't read the whole PWM chapter from the datasheet. Now I accidentally noticed under Enchansed topic following:
Quote
24.4.7 START-UP CONSIDERATIONS
When any PWM mode is used, the application
hardware must use the proper external pull-up and/or
pull-down resistors on the PWM output pins.

This made me confused that do I need to use pull up or pull down resistor for the PWM output pin? And which one do I need and why? I've googled few PIC - Servo examples and on their schematics didn't find any pull x resistors. Could somebody explain what this means. I have a feeling that this is about startup when these pins are floating and if it's critical for them to be eg. 0 it is needed, but I might be wrong.

Then second question regarding the PWM pin, CCPx and timer relationship. Can CCP1 pin RB3 be standard PWM even though it is said to be Enhanced? Or is it must to use pins RA3 and RA4 which are said to be standard PWM? I've already designed the PCB to RB3 CCP1 pin and timer6 for the PWM, but now I'm bit hesitant whether it works.. I assume these others are what's called PxB, PxC and PxD.. Bit confusing.

Thank you in advance
 

Offline woofy

  • Frequent Contributor
  • **
  • Posts: 416
  • Country: gb
    • Woofys Place
Re: PIC16F1847 PWM output need pull up / down resistor
« Reply #1 on: August 14, 2023, 05:30:14 pm »
CCP1 will be fine on RB3.
You don't need pull up/down resistors for your application.
They are needed when you drive H-bridges with a two phase PWM. At reset all pins are inputs until configured by the CPU. Floating pins could enable both high and low drives with rather disastrous consequences. So then pull up/down resistors are used to ensure safe voltages at startup.
 
The following users thanked this post: Veketti

Offline Kim Christensen

  • Super Contributor
  • ***
  • Posts: 1819
  • Country: ca
Re: PIC16F1847 PWM output need pull up / down resistor
« Reply #2 on: August 14, 2023, 05:50:39 pm »
This made me confused that do I need to use pull up or pull down resistor for the PWM output pin? And which one do I need and why? I've googled few PIC - Servo examples and on their schematics didn't find any pull x resistors. Could somebody explain what this means. I have a feeling that this is about startup when these pins are floating and if it's critical for them to be eg. 0 it is needed, but I might be wrong.

Floating pins would be the reason. Imagine you were using the PWM to control a FET/driver as a boost converter. It would be bad if the gate of the FET/driver was floating while the PIC was in reset, and DC drain current started flowing. So in that case you'd use a pulldown to keep the FET/driver off while in reset.

Quote
Then second question regarding the PWM pin, CCPx and timer relationship. Can CCP1 pin RB3 be standard PWM even though it is said to be Enhanced? Or is it must to use pins RA3 and RA4 which are said to be standard PWM? I've already designed the PCB to RB3 CCP1 pin and timer6 for the PWM, but now I'm bit hesitant whether it works.. I assume these others are what's called PxB, PxC and PxD.. Bit confusing.

Sounds like you can make the enhanced do the simple PWM function. Just need to change your code I would think:

Quote
The enhanced PWM module can generate the following
five PWM Output modes:
Single PWM
• Half-Bridge PWM
• Full-Bridge PWM, Forward Mode
• Full-Bridge PWM, Reverse Mode
• Single PWM with PWM Steering Mode
 
The following users thanked this post: Veketti

Online jpanhalt

  • Super Contributor
  • ***
  • Posts: 4279
  • Country: us
Re: PIC16F1847 PWM output need pull up / down resistor
« Reply #3 on: August 14, 2023, 06:26:40 pm »
Some questions you might want to address:
1) What refresh rate (frame frequency) does your digital servo use?  Most common was 50 Hz, but some today are 100 Hz, as I recall.
2) What resolution do you need?  Resolution depends on fosc and frame frequency.   See equation 24-4 and the tables that follow it.

PIC hardware PWM can have difficulty getting down to 50 Hz; although, I have operated a standard 50Hz digital servo at 100 Hz without problems.  I didn't need great resolution.  Another approach is to set an interrupt (e.g,. TMR2) for your refresh rate and do the PWM with firmware.
 
The following users thanked this post: Veketti

Offline VekettiTopic starter

  • Regular Contributor
  • *
  • Posts: 232
  • Country: fi
Re: PIC16F1847 PWM output need pull up / down resistor
« Reply #4 on: August 14, 2023, 07:45:33 pm »
Thanks. I've configured the PWM to 125Hz as I read digital servos should be able to cope up to 200Hz.
Code: [Select]
       TRISB3_bit = 1;
       PR6 = 250; // 125 Hz
       CCP1CON = 0b00111100;
       CCPR1L = 0b01000100; // set dutycycle. 150 = 1,2ms. 275 = 2,2ms
       CCPTMRS = 0b00000010;  // User timer 6 for PWM mode
       TMR6IF_bit = 0;
       T6CON = 0b00000111;             // 111 for prescaler 64
       TRISB3_bit = 0;

I'm using servo "Corona DS339HV" and I haven't found any specification how high Hz will it accept. Fingers crossed the 125Hz is ok. At least it advertizes to be Digital servo..
 

Online jpanhalt

  • Super Contributor
  • ***
  • Posts: 4279
  • Country: us
Re: PIC16F1847 PWM output need pull up / down resistor
« Reply #5 on: August 14, 2023, 08:25:37 pm »
Thank you for the added information.  I have been inactive in the hobby for 10 to 12 years -- too busy on my "hobby farm." The specifications seem modest for modern top-line digital servos but are certainly in line with the JR servos then and others today.  The highest I could go with a JR digital without faults was about 110 - 120 Hz in 2003.  Considering advancements, your plan will probably work. 

John
 

Offline VekettiTopic starter

  • Regular Contributor
  • *
  • Posts: 232
  • Country: fi
Re: PIC16F1847 PWM output need pull up / down resistor
« Reply #6 on: August 19, 2023, 02:07:50 pm »
Just wanted to report back that the 125Hz worked perfectly for this particular servo. Also it seems it didn't matter if the PWM signal was 5VDC and power supply 7.2VDC for servo.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf