Menu

How to Program Arduino UNO R3 With GCBASIC

2015-01-28
2023-06-30
<< < 1 2 3 4 > >> (Page 3 of 4)
  • Anobium

    Anobium - 2022-09-18

    I check the board very, very carefully. I am not aware of any board that is actually correct.

     
    • Keith

      Keith - 2022-09-18

      I have two of these LCD Keypad Shield Modules (Stupid Name) both form the same supplier and less than a fiver a piece. They are slightly different along the top edge where the modifications go. I have been using one of these on a CNC Gear Cutting (Hobbing) Mill for a good while with no problems.

       
      • Anobium

        Anobium - 2022-09-18

        Have a hunt around the web. I cannot remember how to test for the fault. I just always fit the diode.

         
        • Keith

          Keith - 2022-09-18

          I'm only using these UNO's as they are so cheap. A really good saving on creating a PCB, having our little yellow friends (tongue in cheek ) make 10 PCB's Populate it and test.
          I detest the Arduino Language with a passion but now that I can use GCB means I can rattle a project up at a tenth of the cost. Just a pity I couldn't use those LGT328p boards as a substitute for the UNO, Too much cobbling around to make it work the same way with the KeyPad shield.

           
          • Anobium

            Anobium - 2022-09-18

            WAVGAT make a UNO board with an LGT. eBay or Ali is a good place to obtain.

             
            • Keith

              Keith - 2022-09-18

              I've just spent about 20 minutes on Ali and Fleabay looking for WAVGAT LGT328p Uno's ?? Nothing !!.
              Boatloads of Uno's with the Atmega Devices but Now't with an LGT328p

               
              • Anobium

                Anobium - 2022-09-19

                I just did a quick search.. 'LGT8F328P Arduino Uno Compatible Board' I only found NANO board. Odd.

                I should have got 10 !

                 
        • Keith

          Keith - 2022-09-19

          I have found an arduino sketch which checks out if your keypad shield is defective. It is attached as a compressed file.

          I guess it is not very often you are wrong but you're right again - both of mine are reporting as defective or as it say's "BAD"

          * Please be very careful with this "Sketch" I have it on good authority That it actually Puts a short circuit across the MCU ***

           

          Last edit: Keith 2022-09-22
          • Anobium

            Anobium - 2022-09-19

            Keith, Great find. Post the URL to the original source, then, I attribute a Great Cow BASIC port of the sketch.


            I looked at the Sketch. Oh my. It shorts the MCU. Not clever. Let me think if there is a safer way.

             

            Last edit: Anobium 2022-09-19
            • Keith

              Keith - 2022-09-21

              If the sketch to test if the Keypad Shield is causing a short across the MCU I think I had better take it down - What do you think ??

               
              • Anobium

                Anobium - 2022-09-22

                I would post the URL to the original web page - that way folks can find the the sketch and we remove the risk of someone using without full knowledge.

                 
  • stan cartwright

    stan cartwright - 2022-09-18

    Sorry @ Keith I didn't know the hardware you use or experience.

     
    • Keith

      Keith - 2022-09-18

      Hello again Stan, I'm using an Atmega328p Uno with the LCD Keypad Shield. I know I've always said I would never venture onto the Dark Side but hey-ho money talks. these things are as cheap as chips on FleaBay and Ali.

       
  • Anobium

    Anobium - 2022-09-18

    @Kieth - I would change to use of BIT, ALIASing the BITS to a BYTE then you can reset the ButtonState on each read cycle.

    Some code. Shows a BYTE, lots of BITs ALIASed to that BYTE. Then, clear the BYTE and set the BIT within the CASE construct.

    Evan

      Dim ButtonState as Byte  
      Dim ButtonLeft    as Bit  Alias ButtonState.0 
      Dim ButtonRight   as Bit  Alias ButtonState.1
      Dim ButtonUp      as Bit  Alias ButtonState.2
      Dim ButtonDown    as Bit  Alias ButtonState.3
      Dim ButtonSelect  as Bit  Alias ButtonState.4
    
      DIM BTTNPUSH  AS Word
    
    ; MAIN PROGRAM
       WAIT 2 S
       set LCDBacklight on
       PRINT " PRESS A BUTTON"
       WAIT 2 S
     Do Forever
        cls
       BTTNPUSH = READAD10(AN0)
    
       ButtonState = 0
    
       Print BTTNPUSH
      Select Case BTTNPUSH
         Case < 50
          CLS
          PRINT "RIGHT"
          ButtonRight = 1  
         Case > 60 & BTTNPUSH < 200
          CLS
          PRINT "UP"
          ButtonUp = 1
         Case > 200 & BTTNPUSH < 400
          CLS
          PRINT "DOWN"
          ButtonDown = 1
         Case > 400 & BTTNPUSH < 600
          CLS
          PRINT "LEFT"
          ButtonLeft = 1
        Case > 600 & BTTNPUSH < 800
          CLS
          PRINT "SELECT"
          ButtonSelect = 1
      End Select
      wait 2 s
     LOOP
    
     
  • Keith

    Keith - 2022-09-18

    I may have the answer here. What I found is that reading the AD output into a variable results in a logical 0 being delivered and a value of 255 delivered when the button is pressed.

    here is what I have so far in my sandpit. The program is quite big now so I'm only publishing what I have on this part.

    chip mega328P, 16
    option explicit
    include <uno_mega328p.h></uno_mega328p.h>

    ;setup Lcd Parameters
    define LCD_IO 4
    define LCD_NO_RW
    define LCD_SPEED FAST
    define LCD_DB4 DIGITAL_4
    define LCD_DB5 DIGITAL_5
    define LCD_DB6 DIGITAL_6
    define LCD_DB7 DIGITAL_7
    define LCD_RS DIGITAL_8
    define LCD_ENABLE DIGITAL_9
    define LCDBacklight DIGITAL_10

    define XEN = PORTB.5
    define XDIR = PORTB.4
    define XPLS = PORTB.3
    define YEN = PORTB.2
    define YDIR = PORTB.1
    define YPLS = PORTB.0
    define ZEN = PORTD.0
    define ZDIR = PORTD.1
    define ZPLS = PORTD.2
    define ESTOP = PORTD.4
    define XLIMIT_1 = PORTD.5
    define XLIMIT_1 = PORTD.6
    define YLIMIT_1 = PORTD.7
    define YLIMIT_2 = PORTC.5
    define ZLIMIT_1 = PORTC.4
    define ZLIMIT_2 = PORTC.3

    DIM BTTNPUSH AS Word
    DIM XSPMM as Byte
    DIM YSPMM as Byte
    DIM ZSPMM as Byte

    Dim ButtonLeft as Byte
    Dim ButtonRight as Byte
    Dim ButtonUp as Byte
    Dim ButtonDown as Byte
    Dim ButtonSelect as Byte

    dir portb Out ; Set pin direction
    dir portd.0 Out
    dir portd.1 Out
    dir portd.2 Out
    dir portd.3 In
    dir portd.4 In
    dir portd.5 In
    dir portd.6 In
    dir portd.7 In
    dir portc.5 In
    dir portc.4 In
    dir portc.3 In
    set LCDBacklight on

    Do Forever
    BTTNPUSH = READAD10(AN0)
    ButtonRight = BTTNPUSH < 50
    ButtonUp = BTTNPUSH >60 and BTTNPUSH < 200
    ButtonDown = BTTNPUSH >200 and BTTNPUSH < 400
    ButtonLeft = BTTNPUSH >400 and BTTNPUSH < 600
    ButtonSelect = BTTNPUSH >600 and BTTNPUSH < 800
    cls
    If ButtonRight > 0 then
    Print "Right"
    Locate 1,0
    wait 1 s
    End If

    If ButtonUp > 0 then
    Print "Up"
    Locate 1,0
    wait 1 s
    End If

    If ButtonDown > 0 then
    Print "Down"
    Locate 1,0
    wait 1 s
    End If

    If ButtonLeft > 0 then
    Print "Left"
    Locate 1,0
    wait 1 s
    End If

    If ButtonSelect > 0 then
    Print "Select"
    Locate 1,0
    wait 1 s
    End If
    wait 2 s
    LOOP

    If anyone can spot anything incorrect or can be made more streamlined or efficient the please let me know. Many thanks to all.

     
    • Anobium

      Anobium - 2022-09-18

      BTTNPUSH = READAD10(AN0)
      ButtonRight = BTTNPUSH < 50
      ButtonUp = BTTNPUSH >60 and BTTNPUSH < 200
      ButtonDown = BTTNPUSH >200 and BTTNPUSH < 400
      ButtonLeft = BTTNPUSH >400 and BTTNPUSH < 600
      ButtonSelect = BTTNPUSH >600 and BTTNPUSH < 800

      That will work but a tad slower.

       
  • Keith

    Keith - 2022-09-18

    I posted that above before reading your reply above...

    Why are you so bloodywell Clever !!

    Progress at last. Thank you.

     
    • Anobium

      Anobium - 2022-09-18

      Pleasure

       
  • stan cartwright

    stan cartwright - 2022-09-18

    @Keith

    define XEN = PORTB.5
    

    then you use dir portb.5 in
    why not dir XEN in ?

    Is the equals optional ie #define XEN portb.5

     
  • Keith

    Keith - 2022-09-18

    What have I done wrong? My Data Value is incrementing in ASCII characters and symbols ??

    Is there something I haven't told it or perhaps something I have. GRR ! This doesn't happen with Microchip MCU's

     
    • Anobium

      Anobium - 2022-09-19

      Nothing wrong. I would use BITs, you used BYTEs. A working solution either way with a tad more RAM used. I would not worry the UNO has plenty of RAM.

       
  • stan cartwright

    stan cartwright - 2022-09-19

    Is the idea that you use 5 buttons with resistors and and measure the a-d voltage to determine which button was pressed?

     
  • Keith

    Keith - 2022-09-19

    Using BIT instead of BYTE only allows me to store logical values 1 or 0. I need to find what is missing in my code which stops it from displaying ASCII characters and symbols when increment or decrement a numeric value.

    as thus:
    PRINT "X Motor"
    Locate 1, 2
    Print XSPMM
    Locate 1, 6
    Print "Steps/mm"

    If ButtonUp > 0 then
    XSPMM = XSPMM + 1
    EPWrite 0, XSPMM
    WAIT 500 mS
    End if
    If ButtonDown > 0 then
    XSPMM = XSPMM - 1
    EPWrite 0, XSPMM
    WAIT 500 mS
    End if

    I have attached the full project here

     

    Last edit: Keith 2022-09-19
  • Keith

    Keith - 2022-09-19

    I think I have found what is wrong.

    DIM XSPMM as Integer seems to have fixed it

     
  • mmotte

    mmotte - 2022-09-19

    Keith ,
    I do not mean to derail you. But have you looked at GRBL software? It is 3 axis CNC gcode translator which means it has the step and dir outputs plus spindle, coolant , limits(hard and soft), lots more. Free! It would save you time.

    Mike

     
<< < 1 2 3 4 > >> (Page 3 of 4)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.