Replicating Encoder Chip Output With PICBASIC


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2008
    Posts
    4

    Default Replicating Encoder Chip Output With PICBASIC

    If I measure the output of an encoder chip on an oscilloscope (or sound card), how can I replicate the timing and pulses? The datasheets for the encoder (http://www.mosdesign.com.tw/datashee...coder/dM1E.PDF) shows the timing and encoder sequence.
    Attached Images Attached Images  

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sumkrnboy View Post
    If I measure the output of an encoder chip on an oscilloscope (or sound card), how can I replicate the timing and pulses? The datasheets for the encoder (http://www.mosdesign.com.tw/datashee...coder/dM1E.PDF) shows the timing and encoder sequence.
    So, what's the problem?
    You have the datasheet for the IC in question...
    You have an o-scope to measure the output from the example chip that...
    You have in your possession to compare with the circuit that you will build and program.
    Again, what's the issue here?
    Show us any/all code you have written so far, and most surely, somebody here could help you make it work.

  3. #3
    Join Date
    May 2008
    Posts
    4


    Did you find this post helpful? Yes | No

    Default PBP Code

    When I wrote the code like this and individually went through each 0 and 1 bits it outputted fine on the pin

    start:
    low fan_tx
    PulsOut Fan_tx, 35

    pauseus 330
    pulsout fan_tx, 66

    pauseus 660
    pulsout fan_tx, 33

    pauseus 330
    pulsout fan_tx, 66

    pauseus 330
    pulsout fan_tx, 66

    pauseus 660
    pulsout fan_tx, 33

    pauseus 660
    pulsout fan_tx, 33

    pauseus 660
    pulsout fan_tx, 33

    pauseus 660
    pulsout fan_tx, 33

    pauseus 660
    pulsout fan_tx, 33

    pauseus 660
    pulsout fan_tx, 33

    pauseus 660
    pulsout fan_tx, 33

    pauseus 330
    pulsout fan_tx, 66
    pauseus 100
    goto start



    Now when I try to simplify it, I'm not getting any output with the following code from PORTD.5:


    RF VAR bit[12]
    c VAR byte 'number of times to send data stream (loop)
    b VAR byte 'RF(b) stream (loop)
    Output_TX VAR PORTD.5

    Main:
    'lead-in pulse of 350uS followed by
    'Data to output: 010011111110

    RF[0]=0
    RF[1]=1
    RF[2]=0
    RF[3]=0
    RF[4]=1
    RF[5]=1
    RF[6]=1
    RF[7]=1
    RF[8]=1
    RF[9]=1
    RF[10]=1
    RF[11]=0

    Low Output_TX
    For c = 1 To 4 'number of times to send data stream
    PulsOut Output_TX, 35 '350uS lead-in pulse
    For b = 0 To 11
    If RF[b] = 0 Then
    PauseUs 330 '330uS space
    PulsOut Output_TX, 66 '660uS pulse
    Else
    PauseUs 660 '660uS space
    PulsOut Output_TX, 33 '330uS pulse
    EndIf

    Next
    Pause 40 '40mS GAP in between each copy
    Next
    Sleep 2 'Wait 2 seconds before sending data again
    GoTo Main



    Am I missing something here?

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Code:
    RF VAR word : c VAR byte : b VAR byte : output_TX VAR PORTD.5
    output output_tx
    Main: RF=$7f2 : Output_TX = 0 : For c = 1 To 4 : PulsOut Output_TX, 35
     For b = 0 To 11
              If RF.0[b] = 0 Then
                   PauseUs 330 : PulsOut Output_TX, 66    '660uS pulse
              Else
                   PauseUs 660 : PulsOut Output_TX, 33    '330uS pulse
              EndIf
         Next b : Pause 40 : Next C : Sleep 2 : GoTo Main
    Might help to put the variable that you are NEXTing in your NEXT statements...and set the pin that you are using to an output before you use it.
    (The high colonic master strikes again!)
    Last edited by skimask; - 12th May 2008 at 17:36.

Similar Threads

  1. Quadrature encoder and ASM Interrupts. questions..
    By godfodder in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th March 2013, 14:45
  2. Serious Serial Situation Setbacks...
    By Dansdog in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th February 2007, 03:46
  3. HSEROUT Newbie question/problem
    By Mark Scotford in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 11th July 2006, 14:44
  4. analog output values in picbasic
    By taos in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th March 2006, 07:16
  5. encoder wowes
    By wallaby in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 6th December 2005, 21:56

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