PIC18F1320 HPWM on 2 pins


Closed Thread
Results 1 to 22 of 22

Hybrid View

  1. #1
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: PIC18F1320 HPWM on 2 pins

    The PIC18F1320 only has one CCP Module, CCP1. Whereas the Data Sheet claims 1, 2, or 4 outputs, they are all Half- Full-Bridge complimentary outputs of the CCP1 Frequency & Duty Cycle. To achieve your goals, you need a processor with at least 2 CCP Functions. I'm not sure if your project requires an 18F part, but there are several 16F parts with 14/20 pins that incorporate 2+ CCP Modules. Here are some:

    PIC16F1507_8_9 (have 4 CCP Modules)
    PIC16F1615_9 (have 2)
    PIC16F1704_5_8_9 (2)
    PIC16F1713_6-9 (2)

    The list goes on and on. Sometimes you just have to move into the newer processors to achieve your goals.

  2. #2
    Join Date
    Jan 2008
    Location
    Selm, Germany
    Posts
    116


    Did you find this post helpful? Yes | No

    Default Re: PIC18F1320 HPWM on 2 pins

    Hello Mpgmike,

    you are right. I did a HPWM single channel with a 16F88 and it worked great. So I guess its waaaay easier to use two
    PICs than to scramble everything in just one.
    In my experience the use of multiple IF...THEN slows my 40 MHz PIC down to pure uselessness...
    I got the 18F1320 to measure speed and calculate fuel pump speed so I will go for a second PIC to measure temperature and control water pump speed. And show that on an LCD of course. Iīll have to get into hserout , baud rate and such strange things.

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,720


    Did you find this post helpful? Yes | No

    Default Re: PIC18F1320 HPWM on 2 pins

    In my experience the use of multiple IF...THEN slows my 40 MHz PIC down to pure uselessness...
    you can't be doing it the right way

  4. #4
    Join Date
    Jan 2008
    Location
    Selm, Germany
    Posts
    116


    Did you find this post helpful? Yes | No

    Default Re: PIC18F1320 HPWM on 2 pins

    Hello Guys,
    need alittlehelp because iīm totally stuck.
    Trying to send one byte from a PIC16F876A to a PIC16F88 and display it.
    Tried Debug,Serin and donīt get it working.
    Everything works in the proram exept the serout - serin communication.Tried with pullup resistor, baud rates from 1200 to 9600, negative and true.....tried to get samples from this forum, tried samples out of several PIC programming books, I donīt get it.
    Hello World2serin.txtADCINBargraphserout.txtHello World2serin.txt

  5. #5
    Join Date
    Jan 2008
    Location
    Selm, Germany
    Posts
    116


    Did you find this post helpful? Yes | No

    Default Re: PIC18F1320 HPWM on 2 pins

    Hello folks,
    please help because Iīm totally stuck.
    Try to send one byte from a 16F88 to a 16F876A and display it on LCD using DEBUG.
    16F88 measures voltage on one pin and send the variable adval to 16F876A.
    Problem is: the LCD at the 16F876A shows only 4 different charcters: 48 up to 51 or if I change from DEC3 to DEC1 0 to 3.
    Should be 0 to 255 . The Voltage at the analog Input goes the full way from 0V to 4.8V but the LCD shows only 4 different characters which change at about 1/4 of the voltage change, so its proportional to the voltage change .
    I get the message "some configuration words are not in hex" from my PICKIT2 but only when programming the 16F88.

    Transmitter:

    '************************************************* ***************
    '* Name : UNTITLED.BAS *
    '* Author : [select VIEW...EDITOR OPTIONS] *
    '* Notice : Copyright (c) 2012 [select VIEW...EDITOR OPTIONS] *
    '* : All Rights Reserved *
    '* Date : 01.03.2012 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************

    '************************************************* ***************
    '* Name : AnalogDEBUG *
    '* Author : [Davidpower] *
    '* [select VIEW...EDITOR OPTIONS] *
    '* : All Rights Reserved *
    '* Date : 05.12.2017 *
    '* Version : 1.0 *
    '* Notes : 16F88 no LCD *
    '* : Portb.7 analog IN 0-5V *
    '************************************************* ***************


    Include "modedefs.bas"

    Define OSC 4
    Define ADC_BITS 4 ' Set number of bits in result
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uSec
    DEFINE DEBUG_REG PORTB
    DEFINE DEBUG_BIT 2
    DEFINE DEBUG_BAUD 2400
    DEFINE DEBUG_Mode 0
    DEFINE DEBUG_PACING 1000



    CMCON = 7 ' Disable analog comparator
    ANSEL = %01000000 ' set AN6 (RB7) as analog, others to digital
    ADCON1.7 = 1 ' Right justified results... duh... really needed in 8 bits???

    adval VAR WORD


    PAUSE 1000 ' lcd settle time
    DEBUG 10,13

    loop:
    ADCIN 6,adval ' Read channel 6 (RB7)



    DEBUG #adval

    Pause 100



    Goto loop

    End

    Receiver:
    '************************************************* ****************************
    '* MICROCODE STUDIO TIPS *
    '* *
    '* (1) : To get context sensitive help, move your cursor to a PICBasic *
    '* : command and then press F1. *
    '* (2) : Program assumes the PIC is running at 4MHz. To change the default *
    '* : setting (for example, to 20MHz) simply add DEFINE OSC 20 at the *
    '* : top of your program. *
    '* 16F876A 4zeiliges Display, 4 analoge eingänge *
    '* DEBUG PORTB.0
    'This sample program is supplied courtesy of microEngineering Labs Inc *
    '************************************************* ****************************

    ' PicBasic Pro program to display result of
    ' 8-bit A/D conversion on LCD
    ' Connect analog input to channel-0 (RA0)


    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTC
    DEFINE LCD_RSBIT 0
    DEFINE LCD_EREG PORTC
    DEFINE LCD_EBIT 3
    DEFINE LCD_LINES 4
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50



    DEFINE DEBUGIN_REG PORTC
    DEFINE DEBUGIN_BIT 7
    DEFINE DEBUG_BAUD 2400
    DEFINE DEBUGIN_Mode 1


    DEFINE osc 4

    Include "modedefs.bas"

    CMCON = 7
    CVRCON = 0
    adval VAR WORD






    TRISC = %10000000

    TRISA = %11111111 ' Set PORTA to all input
    TRISB = %00000000 ' Set PORTB to all output
    ADCON1 = %00000010 ' Set PORTA analog



    Pause 1000 ' Wait .5 second
    LCDOUT $FE, 2
    loop:

    DEBUGIN 1000,timeout,[adval]
    pause 50
    timeout

    LCDOUT $FE, 2

    Lcdout $fe,$C0 ' Move cursor to beginning of second line
    Lcdout "Ext ", DEC3 adval ' Display the decimal value



    Pause 100 ' Wait .1 second

    Goto loop ' Do it forever



    End

Similar Threads

  1. PIC18F1320 Config Help
    By iw2fvo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 8th June 2013, 07:31
  2. Timer 3 config for HPWM using remappable pins
    By jimbostlawrence in forum General
    Replies: 1
    Last Post: - 5th December 2012, 15:26
  3. PIC - 8 Pins - 6 Output Pins ?
    By DanPBP in forum Off Topic
    Replies: 0
    Last Post: - 22nd October 2007, 01:23
  4. Setting up 5 HPWM pins on 18F4680
    By tcbcats in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 2nd August 2006, 06:54
  5. Compiling error with PIC18F1320
    By mazlan in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 26th November 2004, 02:01

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts