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

Oshonsoft LCD Setup

Discussion in 'Oshonsoft' started by aljamri, Jun 17, 2011.

  1. aljamri

    aljamri Member

    Joined:
    Jun 12, 2006
    Messages:
    694
    Likes:
    6
    Trying to simulate NG Analogue Tutorial eleven, loaded 11.3, (tested it in reality and worked fine), I tried to connect the LCD and changed the analog input but LCD seems not working, and error message appears as in the attached shot.
     

    Attached Files:

    • os.JPG
      os.JPG
      File size:
      168.3 KB
      Views:
      257
  2. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,161
    Likes:
    909
    Location:
    Rochdale UK
    ONLINE
    You have set your data pins to portb 4 -> 7 AND your cmd pins to the same pins If portb is connected to LCD via pins 0 -> 3 select LOW nibble.
     
  3. aljamri

    aljamri Member

    Joined:
    Jun 12, 2006
    Messages:
    694
    Likes:
    6
    Thank you Ian,

    The LCD got connected, but the ADC seems for me not working. I've just adjust both analog channels. the result attached picutre

    edit: it works, it seems that i'm not timming correctly:) thank you Ian
     

    Attached Files:

    • os2.JPG
      os2.JPG
      File size:
      152.9 KB
      Views:
      204
    Last edited: Jun 17, 2011
  4. dave

    Dave New Member

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


     
  5. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,185
    Likes:
    644
    Location:
    Ex Yorks' Hants UK

    hi aljamri,

    From viewing your images you seem to have PORTB high set as the 4 LCD data lines, yet you are using them also as control lines..?????


    Set interface: 4 bit Low on the selection window.
     
    Last edited: Jun 17, 2011
  6. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,185
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi,
    Post your Oshonsoft *.bas file.

    EDIT:
    Do you have this statement in your header

    ADCON1 = 0x84
    it sets all PORTA as adc
     
    Last edited: Jun 17, 2011
  7. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,161
    Likes:
    909
    Location:
    Rochdale UK
    ONLINE
    Ditto!! Post some code please..


    Oops,,, missed that! tutorial 11... 'Im on it
     
    Last edited: Jun 17, 2011
  8. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,161
    Likes:
    909
    Location:
    Rochdale UK
    ONLINE
    Nigel's tutorial looks good... I'll have to run it through Oshonsoft to assemble it..

    Have you just copied the asm file in? No assembly errors..
     
  9. aljamri

    aljamri Member

    Joined:
    Jun 12, 2006
    Messages:
    694
    Likes:
    6
    Sorry Ian, Sorry Eric, I was busy trying to get it work, so I've not noticed your posts.

    Finally with your help I've got it working. Only I could not change the reference voltage as per NG analogue board so instead of 2v input I'm getting 4v on LCD.

    Eric: where to get Oshonsoft *.bas file. ?


    Thank you for all
     
  10. aljamri

    aljamri Member

    Joined:
    Jun 12, 2006
    Messages:
    694
    Likes:
    6
    forgot the attachment :) my bedtime (old people symptoms):D
     

    Attached Files:

    • os3.JPG
      os3.JPG
      File size:
      169.3 KB
      Views:
      157
  11. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,161
    Likes:
    909
    Location:
    Rochdale UK
    ONLINE
    Yep!! Tested with Oshonsoft simulator! Works OK. Did you compile the tutorial using MPASMWIN option and load the hex manually?


    Forget this post then... I never refreshed since my last post...

    Eric thought you were programming in basic (So did I until I re-read your OP)


    It looks to me as if the program uses VREF..
     
    Last edited: Jun 17, 2011
  12. aljamri

    aljamri Member

    Joined:
    Jun 12, 2006
    Messages:
    694
    Likes:
    6
    Last edited: Jun 17, 2011
  13. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,161
    Likes:
    909
    Location:
    Rochdale UK
    ONLINE
    If I knew you had Oshonsoft simulator then, I would have suggested you compile directly with this program...

    The ADCON1 reg in this example is set to 6.. I could do with being 2 or 4 as the Vref isn't set to anything. (for the real device that is)
     
  14. aljamri

    aljamri Member

    Joined:
    Jun 12, 2006
    Messages:
    694
    Likes:
    6
  15. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,161
    Likes:
    909
    Location:
    Rochdale UK
    ONLINE
  16. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,185
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi aljamri
    If you are using the full 10 bits of the adc, ie 1023decimal and the Vadc max is 5V
    To subtract the 1Vdc offset you need to subtract [1/5] *1023 = 205 from the reading.
    This will give a value of 0 thru 818 for 0V to 4V

    If you set the resistor driving the adc input for a maximum of 4.89V
    you will get [4.89/5]*1023 = ~1000 counts, then subtract 200 to leave 800 counts which represents 4V input.
     
    Last edited: Jun 18, 2011
  17. aljamri

    aljamri Member

    Joined:
    Jun 12, 2006
    Messages:
    694
    Likes:
    6
    As I'm not aware about JAVA application and the site owner was giving early warning that he well not accept any questions in this regards, I prefer OshonSoft and if Protuse not of huge size, it would be my first choice.

    Anyway, I've got a fresh question about OshonSoft and I do not know, shall I start a new thread or continue in this. I'll start here and waiting for any advise to make a new one.

    My Question is regarding a suggested ADC routine by be80b2 in " http://www.electro-tech-online.com/threads/reading-4-20-ma-on-lcd-using-pic16f876a.119563/ " post #17. When I made the circuit, the LCD shows only square, so I thought of my hardware problem, so that I decided to simulate it with OshonSoft and see what is the result. It seems the routine is updating LCD port PORTB one time, and then it goes for endless loop without updating it any more. The attached picture shows the result
     

    Attached Files:

    • os3.JPG
      os3.JPG
      File size:
      169.3 KB
      Views:
      164
  18. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,185
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi aljamri,
    Please post the full code and I will check it out on Oshonsoft.
     
    Last edited: Jun 18, 2011
  19. aljamri

    aljamri Member

    Joined:
    Jun 12, 2006
    Messages:
    694
    Likes:
    6
    Sorry, wrong attachment, whenever I want to edit my post, it did not go for Advanced.

    EDIT: Hi Eric here is the code:

    Code (text):

     
    char message1[] = "ADC Value= ";
     char *value = "0000";
     unsigned int ADC_Value;
    void main() {
      ADCON0 = 0b11000000;
      ADCON1 = 0b10001111;
      TRISA  = 0xFF;              // PORTA is input
      TRISB  = 0;                 // PORTB is output
      Lcd_Init(&PORTB);                 // Initialize LCD

      do {
           adc_value = ADC_Read(0);
       value[0] = adc_value/1000 + 48; // Add 48 to get character value
       value[1] = (adc_value/100)%10 + 48;
       value[2] = (adc_value/10)%10 + 48;
       value[3] = adc_value%10 + 48;
       Lcd_Out(1,11,value);
       Delay_ms(2000);
      } while(1);
    }
     
     

    Attached Files:

    • OS4.JPG
      OS4.JPG
      File size:
      170.1 KB
      Views:
      153
    Last edited: Jun 18, 2011
  20. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,185
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    Hi,
    Thats not Oshonsoft code.?
     
  21. aljamri

    aljamri Member

    Joined:
    Jun 12, 2006
    Messages:
    694
    Likes:
    6
    OOPs, sorry, I don't know how to get Oshon code.
     

Share This Page