Voltage output from PIC16f628A


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    you just need to enter the OSC speed and expected frequency. it will give you...
    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1168&stc=1&d=116295770 1">
    There, you have the
    prescaller => 1:16 => see T2CON setting in your datasheet
    PR2 => 155 => directly

    It also give you the value for 100% duty cycle => 625

    If you want to set different DutyCycle, move the scroll bar at the top right. The duty value will be reported in the 'results' section at the bottom.

    Not much.
    Attached Images Attached Images  
    Last edited by mister_e; - 8th November 2006 at 03:55.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #2
    bennamanna's Avatar
    bennamanna Guest


    Did you find this post helpful? Yes | No

    Smile

    Gday again,

    Thanks for that info. I changed the PR2 as per your calculation. It still does not seem to give the same value as I enter in the terminal application. If I am correct in my coding, if I send it 100 with a terminal app 100 should display on the LCD and it should set the duty cycle to 100. This is not the case. It says 34 on the LCD and reflects that in the duty cycle.

    Any ideas?

    Thanks,

    Ben

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    I don't know wich terminal software you're using but be sure it send ASCII character and use the right modifier in your Serin/Serin2/DEBUGIN/HSERIN line.

    Look for # or DEC.

    Also, make sure your terminal software don't send cr and lf character.

    Once you're sure of it, you should have better results.

    If you send 100 and receive it correctly, you should have a 16% duty cycle.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    bennamanna's Avatar
    bennamanna Guest


    Did you find this post helpful? Yes | No

    Smile

    Gday,

    I am using serial communicator that is with microcode studio. I cant see a setting to ensure it is sending ascii. I made sure it was not sending cr and it made no diference.

    The code I am using is below.

    NCLUDE "modedefs.bas" ' Include serial modes
    SI VAR PORTB.1 ' Serial Input pin
    B0 VAR BYTE
    Define OSC 10

    Define LCD_DREG PORTA ' RA0..3
    Define LCD_DBIT 0
    Define LCD_RSREG PORTA ' RA6
    Define LCD_RSBIT 6
    Define LCD_EREG PORTA ' RA4
    Define LCD_EBIT 4
    Define LCD_BITS 4
    TRISA = 0
    TRISB = 0
    CMCON = 7

    Pause 1000 ' Wait for LCD to startup

    duty VAR BYTE ' Duty cycle value (CCPR3L:CCP3CON<5:4>)

    TRISB.3 = 0 ' Set PORTB.5 (CCP3) to output
    CCP1CON = %00001100 ' Set CCP3 to PWM
    T2CON = %00010101 ' Turn on Timer2, Prescale=4

    PR2 = 155 ' Set PR2 to get 1KHz out
    duty = 100 ' Set duty cycle to 20%

    loop:
    SerIn SI,T9600,,duty
    if duty > 625 then
    LCDOut $FE,1 ' Clear LCD screen
    LCDOut "Duty to great" ' Display line 1
    goto loop
    endif

    CCP1CON.4 = duty.0 ' Store duty to registers as
    CCP1CON.5 = duty.1 ' a 10-bit word
    CCPR1L = duty >> 2

    'duty = duty + 5 ' Increase duty cycle
    LCDOut $FE,1 ' Clear LCD screen
    LCDOut # duty ' Display line 1

    GoTo loop ' Do it forever

    Any other ideas why it is not receiving the same as I send it?

    Thanks,

    Ben

  5. #5
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    hi Ben,

    Since our PICs are serial processors, at least for now, and must execute the instructions serially, that is to say one line or instruction at a time, you will never get Serin and Serout commands working at the same time.

    If you use hardware USART, then it will be working in the background, so that you can receive something at the same time you send it.


    -----------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    As i said before... look for # modifier... it convert your ASCII string to a DECIMAL value.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    bennamanna's Avatar
    bennamanna Guest


    Did you find this post helpful? Yes | No

    Smile

    Hi sayzer,

    Thanks for your reply. I did not think that my code was trying to use ser in and out at the same time? Could you indicate where I am doing this? Thanks mate.

    mister_e,

    Thanks once again. I'm sorry if I'm making you repeat your self. As stated before I am a beginner. I had however already played with # in my code. I tested it with and without. With out # all i get is jargon.

    Thanks,

    Ben

Similar Threads

  1. Changing bits in a byte for multiple output
    By tazntex in forum Serial
    Replies: 3
    Last Post: - 11th August 2008, 19:10
  2. What's the voltage on output pin when it's HIGH?
    By TonyA in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 23rd April 2008, 15:06
  3. make a low voltage output from a PIC pin
    By emptyset in forum General
    Replies: 1
    Last Post: - 8th February 2008, 19:20
  4. Serious Serial Situation Setbacks...
    By Dansdog in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th February 2007, 03:46
  5. Help with final project
    By OvERKiLL in forum General
    Replies: 4
    Last Post: - 15th December 2006, 20:35

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