Serial LCD on 12F675


Closed Thread
Results 1 to 5 of 5
  1. #1
    anj's Avatar
    anj Guest

    Default Serial LCD on 12F675

    Gday all
    I have been using a 12F675 to do a 10bit ADC then output a corresponding 28Hz PWM signal ( manually generated ), to control a small DC motor.
    If ADC is > 512 first pin held low and second pin outputs pulses.
    If ADC is < 512 first pin outputs pulses and second pin held low.
    Thus i get speed and direction from a single pot.

    To validate my ADC readings i hooked up a serial LCD to output the values and all i got was garbage.
    When i stopped generating the PWM it all worked again.

    I then tried just turning on two leds, ie
    one on if ADC > 512 and
    other for ADC < 512.
    LCD still gave garbage
    As such, it appears that turning on other pins can affect what goes out on the SEROUT pin hence resulting in my LCD losing the plot ????
    Setup is ADC on GP0
    LCD on GP1
    LEDs/outputs on GP4/GP5
    config bit set to 21EC ie internal oscillator
    Power supply is good and i have current limiting resistors on the LEDS. ( Total power draw is within specs for chip )
    Any ideas on if the 12F675 suffers crosstalk, resets itself internally between operations??
    I have tried pulldown resistors on GP1 and that didnt help.
    Andrew

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Since you are running on internal oscillator, what speed (baud rate) are you sending to your Serial LCD? It is quite possible that with additional loading on the 5v line there is a small effect on the internal oscillator (which is only approximately 4MHz at best) and is sufficient for it to introduce significant errors at higher baud rates. Drop your baud rate down to 2400 or less.

    Melanie

  3. #3
    anj's Avatar
    anj Guest


    Did you find this post helpful? Yes | No

    Default The plot thickens

    Gday Melanie
    Thks for the reponse but I think the problem is a bit deeper.
    Ps i am running at 2400baud

    My serial LCD controller has a switchable data inverter and i was using my Pic in True mode to match what it was set at.
    In this mode it worked until i tried to set another pin on the Pic, in which case it started to fail again. This was intermittent, but i have now traced it back to if there is a pause after the pin is set.
    I swapped the LCD mode and then drove inverted from the Pic and it worked perfectly under all circumstances.
    Next i stuck a CRO on the serout pin to see what was happening.
    When just doing a serout, in True mode, the trace defaults to high and pulls low on data.
    In Inverted mode it defaults to low and pulls high on data.
    After any other pin is set, and then followed by a pause, the serout pin is actively pulled low during the pause time.
    This occurs in both modes, hence resulting in the LCD going haywire in true mode, as it should be pulled high in this case.
    I then thought i'd be sneaky, and if in true mode, manually force the serout pin high just before i set the other pins, to keep it high until the next serout. ie
    GPIO.1 = 1 <- serout pin
    GPIO.4 = 0
    GPIO.5 = 0
    to my dismay, after the last line, GPIO.1 appears to have been pulled low again, and it fails as per usual
    then i tried
    GPIO.4 = 0
    GPIO.5 = 0
    GPIO.1 = 1
    and this works like a charm, with GPIO.1 staying high
    I now know how to fix it but i think there is some wrong logic going on somewhere when the serout mode is true.

    Andrew

    test program used as per below
    failure is when pot is roughly centred, comes good each side of centre
    --------------------------------------------------------------------------------------------
    DEFINE ADC_BITS 10 ' Set number of bits in result
    DEFINE ADC_CLOCK 3 ' Set clock source (rc = 3)
    DEFINE ADC_SAMPLEUS 50 ' Set sampling time in microseconds
    serpin con 1 ' lcd output pin
    sermode con 0 ' output mode driven true, fails after any pin is set???
    'sermode con 4 ' output mode driven inverted

    XVal var word
    ADCON0 = %10000001 ' Configure and turn on A/D Module:
    ' Right justify result, use Vdd pin, channel 0
    TRISIO = %00000001 '

    init: 'initialise LCD
    pause 1000 ' wait for lcd to start
    SerOut serpin, sermode, [ $FE, 1 ] 'clear screen 2x to setup
    pause 100
    SerOut serpin, sermode, [ $FE, 1 ]
    pause 100
    start:
    ADCIN 0, XVal
    pause 250
    loopret:
    if ( XVal > 470 ) and ( XVal < 550 ) then
    GPIO.1 = 1 ' if this is uncommented it fails
    GPIO.4 = 0
    GPIO.5 = 0
    ' GPIO.1 = 1 ' if this is uncommented it works
    endif
    pause 750
    SerOut serpin, sermode, [ $FE, 2, #Xval, " " ] 'Display the decimal value
    goto start
    end

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    I'll see if I can find a few minutes at the end of the day and try to replicate your problem.

  5. #5
    anj's Avatar
    anj Guest


    Did you find this post helpful? Yes | No

    Default Serout affected by other pins

    Gday Melanie
    I have continued mucking around with this and have eliminated the LCD and ADC, and now have a very basic example that fails
    on demand.
    To allow me to get a decent CRO result i have also reset the pause time.
    'set CRO timebase to 2mS for best results
    -----------------------------------
    serpin con 1 ' serial output pin
    sermode con 0 ' output mode driven true, fails after any pin is set???
    ANSEL = 0
    TRISIO = %00000000 '
    start:
    SerOut serpin, sermode, [ "T" ]
    1) GPIO.1 = 1 <-serout pin
    2) GPIO.4 = 0
    3) GPIO.1 = 1 <-serout pin
    pause 6
    goto start
    end
    -----------------------------------
    results i get are
    Pulse OK with idle time HIGH ( Ie std serout no other ops )
    1), 2) and 3) commented out. ( std serout )
    1) only commented out.

    Pulse OK with idle time LOW ( Ie incorrect )
    3) only commented out.
    1) and 3) commented out.

    over to you.
    Andrew

    Dont worry, ive got it. I found an FAQ on the MEL american site re the 16F675 defaulting its comparator to ON. I have been using a 16F88 up till now and that defaults to off, hence i didnt even think to check it.
    Interestingly enough, my serout was on the -ve comparator input, so not sure why it behaved that way.
    Anyway, i add CMCON = 7 at the top and she appears to be happy. Sorry for wasting yr time.
    Andrew

    Last edited by anj; - 1st April 2004 at 06:36.

Similar Threads

  1. LCD serial backpacks
    By Archangel in forum Serial
    Replies: 67
    Last Post: - 30th December 2010, 04:51
  2. Please help with EDE702 - Serial to LCD interface
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th October 2008, 02:48
  3. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  4. Serial LCD
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th November 2007, 08:31
  5. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07

Members who have read this thread : 1

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