1. 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.
    Dismiss Notice

Adding A/Ds to 12F683 in Oshonsoft

Discussion in 'Oshonsoft' started by camerart, Jan 29, 2014.

  1. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,304
    Likes:
    914
    Location:
    Rochdale UK
    ONLINE
    With all this to-ing and fro-ing I lost the plot!!! camerart Have you the latest full code..
     
  2. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,396
    Likes:
    11
    Location:
    Dorset UK.
    I lost it a couple of days ago, so I know what you mean:)

    The code posted in #24 will work if the T1CON is commented out, so if you turn up a voltage to '>100' in either A/D one or the other LEDs will go on till it is lowered again, but it is running far too fast for you to see the 'Start up LED' flashing. Once T1CON is un-commented, then GP5 will not light, perhaps no LEDs will light. It all looks ok, in the simulator, but not real life (for me)

    Camerart
     
  3. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,304
    Likes:
    914
    Location:
    Rochdale UK
    ONLINE
    At the moment..

    AN0 increased to 100... Red LED comes on..
    AN1 increased to 100 Green LED comes on..
    Red LED flashes according to value of AN0 ( On time )
    Red LED flashes according to value of AN1 ( Off time )​
    Or....
    AN1 increased to 100... Green LED comes on..
    AN0 increased to 100 Red LED comes on.. Red LED flashes according to value of AN0
    Red LED flashes according to value of AN0 ( On time )
    Red LED flashes according to value of AN1 ( Off time )​

    If both AN0/1 are lower than 100 then both LED's are off..

    This makes no difference if T1CON is on or off...
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,396
    Likes:
    11
    Location:
    Dorset UK.

    Are you doing this with an actual 12F683 or on the simulator? It works for me also in the simulator, but not in circuit. I've sent Eric some chips to try.
     
  6. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi,
    Even the IF tests are remmed out the problem shows in simulation.
    Camerart, try this.
    Rem out as the following lines...
    Use the Program Tracking Option.
    When it executes the Break , single step thru the code.
    rled will become set when the rled=1 statement is executed.
    But will reset when you execute the gled=1 statement! this should not happen

    Do you follow that OK.?

    Code (text):


    loop:
    'Adcin 0, an0  'Sets first pulse
    'Adcin 1, an1  'Sets second pulse

    Break
    'If an0 >= 100 Then
    rled = 1  'ON IN SIMULATOR = OFF
    'firstpulse = an0
    'WaitMs an0
    'firstpulse = 0
    'Else
    'rled = 0  'OFF IN SIMULATOR = ON
    'Endif

    'If an1 >= 100 Then
    gled = 1  'ON IN SIMULATOR = OFF
    'secondpulse = an1
    'WaitMs an1
    'secondpulse = 0
    'Else
    'gled = 0  'OFF IN SIMULATOR = ON
    'Endif


    Goto loop
     
     
  7. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi camerart,
    Using MPLAB, the problem is with your ANSEL
    you have ANSEL=47; which makes GP2 analog!

    make it ANSEL=43 and retry
    ANSEL = %01000011
    E
     
  8. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,396
    Likes:
    11
    Location:
    Dorset UK.
    Stepping through the code from the BREAK command. At 'rled = 1' then RLED turns on, at 'gled' = 1 then GLED turns on and RLED stays on.

    If I run the simulator at 'NORMAL' speed from the beginning, then the simulator stops at 'rled = 1' and sets the speed rate to STEP BY STEP.

    I'm not sure if I did what you were asking?
     
  9. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,304
    Likes:
    914
    Location:
    Rochdale UK
    ONLINE
    camerart !! I simulate in ISIS at full speed.... The code from post #24 doesn't have any "t" variable in the loop so timer 1 isn't doing anything??

    What Eric said is correct... ANSEL should be 0x43... or 0x53 ( to increase the aqu time a little...)
     
  10. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,396
    Likes:
    11
    Location:
    Dorset UK.
    I tried 0x43 and 0x53. Same symptoms on the circuit.

    Eric will receive the Chips in a day or two, best wait till he's had a go with them.
     
  11. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    OK, will wait for the PIC's, but that ANSEL was incorrect at 47.

    When that circuit is operating correctly, what are you expecting to see on the LED's etc.?? just summarise.

    E
     
  12. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,396
    Likes:
    11
    Location:
    Dorset UK.
    I've changed the ANSEL.

    The start-up flashes should turn on/off about a second. When the A/D 'voltages' go up and down, then the corresponding LED will turn on and off. First try commenting out T1CON.
     
  13. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi camerart,
    The 12F683 package you posted has not arrived as at 11:00 Today.
    I have built the project board ready for your PIC
    E
     
  14. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,396
    Likes:
    11
    Location:
    Dorset UK.
    Hi E,

    I posted it a couple of days ago, 1st class, so it should be there by now. I put the PICs in a letter, and I'm wondering now if it haven't pass the post office slot test. If that's the case you might be charged parcel post or something. If so let me know and I'll send the extra postage. Perhaps I should have flattened the legs:)

    C.
     
  15. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,304
    Likes:
    914
    Location:
    Rochdale UK
    ONLINE
    eric.... Are you back in the RSA?
     
  16. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi C,
    If they dont turn up I will buy 6 pieces.
    Dont worry about the postage.
    E

    hi I,
    No, I am in the UK, quite ill at the moment with a stomach bug thats doing the rounds.
     
  17. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,304
    Likes:
    914
    Location:
    Rochdale UK
    ONLINE
    ??? ANSEL 0x43 there are only two adc inputs....

    camerart So nothing happens on a real chip.... Usually this is down to osc settings.. The reason I say this is because this is the only thing ISIS doesn't simulate!!
     
  18. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,396
    Likes:
    11
    Location:
    Dorset UK.
    E,
    I asked today at the post office, and they said true it wouldn't go through the small letter slot (I haven't kept up with today's postal system!) and you will most probably get a £1;50 + postage bill. Sorry about that, and that you aren't well. Hope you get better soon.

    I'm happy to send some more, properly this time:)

    Camerart.
     
    Last edited: Feb 7, 2014
  19. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,396
    Likes:
    11
    Location:
    Dorset UK.
    I,
    Correct, nothing happens on the real chip, but looks ok in the simulator. Earlier in the thread I said it might be the clock, so what you say sounds correct. It appears that either if something is connected to the 'clock' pins, or perhaps the inputs are set to IN, then it stops the clock regulator, which seems to change the WAITMS. Anyway, one way or another Eric will have some to test. Unless of course it's ME!

    UPDATE: I just tried a test with the initial 'start up flashes' with 100X WAITMS 1000. This did slow it down a bit, and I estimate that it would need 250X WAITMS 1000s to equal 1 second.

    Camerart.
     
    Last edited: Feb 7, 2014
  20. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,304
    Likes:
    914
    Location:
    Rochdale UK
    ONLINE
    You haven't got the frequency set wrong? I mean in the IDE..... The chip has a really accurate internal crystal... Also make sure the INTOSC is set to IO function not clockout...
     
  21. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,396
    Likes:
    11
    Location:
    Dorset UK.
    The frequency set to 4Mhz. the INTOCS is INTOSCIO. I chose the chip because of its timing accuracy.

    Let's see what Eric comes up with, I've been known to make mistakes!

    Camerart.
     

Share This Page