Arduinos and Microcontrollers ref: Rotary Table Mew 249

Advert

Arduinos and Microcontrollers ref: Rotary Table Mew 249

Home Forums Electronics in the Workshop Arduinos and Microcontrollers ref: Rotary Table Mew 249

Viewing 25 posts - 76 through 100 (of 243 total)
  • Author
    Posts
  • #270857
    SillyOldDuffer
    Moderator
      @sillyoldduffer

      Hi Emgee,

      I've been playing too and have a similar problem. I'm pretty sure the issue is the bit of code that works out which key is being pressed. It's the very last function at the end of the Sketch and it looks like this:

      int read_LCD_button() // routine to read the LCD's buttons
      {
      int key_in;
      delay(ADSettleTime); // wait to settle
      key_in = analogRead(0); // read ADC once
      delay(ADSettleTime); // wait to settle
      // average values for my board were: 0, 144, 324, 505, 742
      // add approx 100 to those values to set range

      if (key_in > 850) return NO_KEY;
      if (key_in < 70) return RIGHT_KEY;
      if (key_in < 250) return UP_KEY;
      if (key_in < 450) return DOWN_KEY;
      if (key_in < 650) return LEFT_KEY;
      if (key_in < 850) return SELECT_KEY;

      }

      The way the code works is that pressing a key generates a voltage that's measured by the arduino. The voltages can vary between individual LCD boards. Mine generates voltages that don't quite line up with the values in the sketch. I get:.

      • NO_KEY 1023 (This is OK)
      • RIGHT_KEY 0 (This is OK)
      • UP_KEY 99 (This is OK)
      • DOWN_KEY 255 (This is only just OK)
      • LEFT_KEY 409 (This is WRONG – the sketch thinks the DOWN_KEY has been pressed)
      • SELECT_KEY 638 (This is WRONG – the sketch thinks the LEFT_KEY has been pressed)

      Easily fixed. I change these lines in the function to read:

      if (key_in > 850) return NO_KEY;
      if (key_in < 70) return RIGHT_KEY;
      if (key_in < 230) return UP_KEY;
      if (key_in < 350) return DOWN_KEY;
      if (key_in < 450) return LEFT_KEY;
      if (key_in < 850) return SELECT_KEY;

      You can use the IDE's monitor to find out what voltages are stored in key_in when the various buttons are pressed. To do this, add the command

      Serial.begin(9600);

      to the function called setup at the beginning of the sketch.

      Then add Serial.println( key_in ) to the read_LCD_button function as shown:

      int read_LCD_button() // routine to read the LCD's buttons
      {
      int key_in;
      delay(ADSettleTime); // wait to settle
      key_in = analogRead(0); // read ADC once
      delay(ADSettleTime); // wait to settle
      // average values for my board were: 0, 144, 324, 505, 742
      // add approx 100 to those values to set range

      Serial.println( key_in ); // for debugging

      if (key_in > 850) return NO_KEY;
      if (key_in < 70) return RIGHT_KEY;
      if (key_in < 230) return UP_KEY;
      if (key_in < 350) return DOWN_KEY;
      if (key_in < 450) return LEFT_KEY;
      if (key_in < 850) return SELECT_KEY;

      }

      Verify and Upload the sketch, then turn on the monitor with Tools->Serial Monitor. It may be necessary to set it to 9600 Baud. (bottom right of screen)

      The monitor should start spewing the number 1023. When you press a button a different number will appear in the stream. This is the value your LCD Board uses to signal that key is pressed. Record the value produced by each key and compare it with the values in the Sketch, changing the sketch as necessary.

      After you've got it working it's tidy to remove the Serial commands. The Sketch will still work if you leave them in.

      Hope that makes sense!

      Dave

       

       

      Edited By SillyOldDuffer on 09/12/2016 17:03:14

      Advert
      #270863
      Journeyman
      Participant
        @journeyman

        Also playing with this, first time with Arduino. More by luck than judgement my key presses seem to work OK and the functions work as per the program. I was testing with the UNO and LCD shield just plugged into the USB port on my PC. I was wondering if the available output from the USB port was on the limit it might affect the key press analogue voltages as it is just a resistor divider chain and if the starting 5v is below spec could have strange consequences down the line. I hasten to add that I have no experience or knowledge in this area! Just trying to learn and keep the little grey cells moving…

        John

        #270867
        Engine Builder
        Participant
          @enginebuilder

          Sillyoldduffer, your not so silly!

          I do not quite understand, as a Arduino virgin, where I should put the line Serial.begin(9600);

          I see void setup() { in the sketch.

          Anyway I just changed the key_in values to the same as your and it seems to work now.

          Thanks for the help.

          I would like to check what values my keys are giving though so could you clarify where to add that Serial.begin line please.

          #270869
          Roger Williams 2
          Participant
            @rogerwilliams2

            My first time with the Arduino Uno too, and after getting something like " done uploading ",, I get bugger all on the LCD apart from the light !!. Oops. Any thoughts anyone please, bearing in mind I dont really know what Im doing.

            #270870
            SillyOldDuffer
            Moderator
              @sillyoldduffer
              Posted by Engine Builder on 09/12/2016 17:39:26:

              Sillyoldduffer, your not so silly!

              I do not quite understand, as a Arduino virgin, where I should put the line Serial.begin(9600);

              I see void setup() { in the sketch.

              Anyway I just changed the key_in values to the same as your and it seems to work now.

              Thanks for the help.

              I would like to check what values my keys are giving though so could you clarify where to add that Serial.begin line please.

              Trust me : I am quite Silly, quite old and a bit of a duffer!

              the Serial.begin can go anywhere inside setup(). This is where I put it:

              void setup()
              {
              // Create some custom characters for the lcd display
              byte c_CW[8] = {0b01101,0b10011,0b10111,0b10000,0b10000,0b10000,0b10001,0b01110}; //Clockwise
              byte c_CCW[8] = {0b10110,0b11001,0b11101,0b00001,0b00001,0b00001,0b10001,0b01110}; // CounterClockWise
              #ifdef Fahrenheit
              byte c_DegreeF[8] = {0b01000,0b10100,0b01000,0b00111,0b00100,0b00110,0b00100,0b00100}; // degreeF
              #endif
              #ifdef Celsius
              byte c_DegreeF[8] = {0b01000,0b10100,0b01011,0b00101,0b00100,0b00100,0b00101,0b00011}; // degreeC
              #endif
              lcd.createChar(1,c_CW);
              lcd.createChar(2,c_CCW);
              lcd.createChar(3,c_DegreeF);

              Serial.begin(9600);
              // begin program

              Glad it's working!

              Dave

              #270871
              SillyOldDuffer
              Moderator
                @sillyoldduffer
                Posted by Roger Williams 2 on 09/12/2016 17:42:35:

                My first time with the Arduino Uno too, and after getting something like " done uploading ",, I get bugger all on the LCD apart from the light !!. Oops. Any thoughts anyone please, bearing in mind I dont really know what Im doing.

                This could be another easy one I hope. Top left on the LCD DIsplay is a Blue Box with a small brass screw on stop. This is the multi-turn potentiometer that controls contrast. Try turning it with a small screwdriver (could need to go either way). Be gentle and don't overdo it – I broke one once.

                Dave

                #270891
                JA
                Participant
                  @ja
                  Posted by SillyOldDuffer on 09/12/2016 17:54:08:

                  Posted by Roger Williams 2 on 09/12/2016 17:42:35:

                  My first time with the Arduino Uno too, and after getting something like " done uploading ",, I get bugger all on the LCD apart from the light !!. Oops. Any thoughts anyone please, bearing in mind I dont really know what Im doing.

                  This could be another easy one I hope. Top left on the LCD DIsplay is a Blue Box with a small brass screw on stop. This is the multi-turn potentiometer that controls contrast. Try turning it with a small screwdriver (could need to go either way). Be gentle and don't overdo it – I broke one once.

                  Dave

                  The photograph was up-side-down in the article (just to show that I have had a good read of what is a thought provoking article).

                  JA

                  #270894
                  Engine Builder
                  Participant
                    @enginebuilder

                    sillyoldduffer,

                    I manged to alter the sketch to verify the key voltages and got similar results to your one.

                    If it helps other builders my LCD shield is badged DF ROBOT (Drive the Future)

                    This is the results I got.

                    • NO_KEY 1023
                    • RIGHT_KEY 0
                    • UP_KEY 98
                    • DOWN_KEY 253
                    • LEFT_KEY 408
                    • SELECT_KEY 639
                    #270897
                    SillyOldDuffer
                    Moderator
                      @sillyoldduffer
                      Posted by JA on 09/12/2016 19:33:28:

                      Posted by SillyOldDuffer on 09/12/2016 17:54:08:

                      Posted by Roger Williams 2 on 09/12/2016 17:42:35:

                      The photograph was up-side-down in the article…

                      JA

                      My punishment for specifically referring to 'top left' of the photo in the text! Glad you found the article thought provoking, rather than baffling (I hope).

                      Cheers,

                      Dave

                      #270898
                      SillyOldDuffer
                      Moderator
                        @sillyoldduffer
                        Posted by Engine Builder on 09/12/2016 19:39:26:

                        sillyoldduffer,

                        I manged to alter the sketch to verify the key voltages and got similar results to your one.

                        If it helps other builders my LCD shield is badged DF ROBOT (Drive the Future)

                        This is the results I got.

                        • NO_KEY 1023
                        • RIGHT_KEY 0
                        • UP_KEY 98
                        • DOWN_KEY 253
                        • LEFT_KEY 408
                        • SELECT_KEY 639

                        Good work, you're officially a computer hacker now!

                        My LCD is a DF Robot as well – perhaps they all produce voltages like that.

                        I haven't got any further than getting the arduino and display to work. I wrongly thought I had a suitable motor, lack of which has taken the wind out of my sales…

                        Cheers,

                        Dave

                        #270901
                        Engine Builder
                        Participant
                          @enginebuilder
                          Posted by SillyOldDuffer on 09/12/2016 20:07:18:

                          Posted by Engine Builder on 09/12/2016 19:39:26:

                          sillyoldduffer,

                          I manged to alter the sketch to verify the key voltages and got similar results to your one.

                          If it helps other builders my LCD shield is badged DF ROBOT (Drive the Future)

                          This is the results I got.

                          • NO_KEY 1023
                          • RIGHT_KEY 0
                          • UP_KEY 98
                          • DOWN_KEY 253
                          • LEFT_KEY 408
                          • SELECT_KEY 639

                          Good work, you're officially a computer hacker now!

                          My LCD is a DF Robot as well – perhaps they all produce voltages like that.

                          I haven't got any further than getting the arduino and display to work. I wrongly thought I had a suitable motor, lack of which has taken the wind out of my sales…

                          Cheers,

                          Dave

                          Thanks for the help.

                          I'm on the next step now, ordered the driver!

                          #270913
                          Roger Williams 2
                          Participant
                            @rogerwilliams2

                            Silly Old Duffer, thanks for that about the potentiometer, I tried many turns both ways but still nothing. I might try uploading again to see what happens.

                            #270921
                            JA
                            Participant
                              @ja
                              Posted by SillyOldDuffer on 09/12/2016 19:56:37:

                              Posted by JA on 09/12/2016 19:33:28:

                              Posted by SillyOldDuffer on 09/12/2016 17:54:08:

                              Posted by Roger Williams 2 on 09/12/2016 17:42:35:

                               

                               

                              The photograph was up-side-down in the article…

                              JA

                              My punishment for specifically referring to 'top left' of the photo in the text! Glad you found the article thought provoking, rather than baffling (I hope).

                              Cheers,

                              Dave

                              Certainly not baffling although I would not have started with a hot air engine.

                              Sorry. I think I have cross linked two threads again (that is this one is about the rotary table and I am referring to the hot air engine data logger).

                              JA

                              Edited By JA on 09/12/2016 23:23:54

                              #270948
                              Carl Wilson 4
                              Participant
                                @carlwilson4

                                Interesting stuff, just seen all this. I’d no idea that the different Lcd/key pad Shields outputted different voltages.

                                Regarding the too bright Lcd, exactly same thing happened to me. Just adjusted the contrast pot as Dave points out.

                                #271169
                                SillyOldDuffer
                                Moderator
                                  @sillyoldduffer
                                  Posted by Roger Williams 2 on 09/12/2016 22:27:15:

                                  Silly Old Duffer, thanks for that about the potentiometer, I tried many turns both ways but still nothing. I might try uploading again to see what happens.

                                  Hi Roger,

                                  Oh dear you might have a dud.

                                  Uploading again is the right thing to do. Keep an eye on the console display at the bottom for error messages.

                                  The other thing to check is that all the LCD plug pins are correctly located n the Arduino socket. I once managed to bend one behind…

                                  Good luck,

                                  Dave

                                  #271184
                                  Roger Williams 2
                                  Participant
                                    @rogerwilliams2

                                    S O Duffer, thanks for your help, I will have another look at it tomorrow. Cheers.

                                    #271185
                                    Engine Builder
                                    Participant
                                      @enginebuilder

                                      Just been looking for a suitable motor for this project. The one in the article is said to be 24 kg/cm torque but looking at the source metioned I cannot see one with that specification.

                                      I am confused too about the voltage rating of these motors. I assume a 12v is needed as that is the supply voltage.

                                      The one closest to the specified one has a rated voltage of 3v and the one used in the Liming article seems to be 8.6.

                                      i am confused what to get!

                                      #271190
                                      Neil Wyatt
                                      Moderator
                                        @neilwyatt
                                        Posted by Engine Builder on 11/12/2016 14:05:41:

                                        Just been looking for a suitable motor for this project. The one in the article is said to be 24 kg/cm torque but looking at the source metioned I cannot see one with that specification.

                                        I am confused too about the voltage rating of these motors. I assume a 12v is needed as that is the supply voltage.

                                        The one closest to the specified one has a rated voltage of 3v and the one used in the Liming article seems to be 8.6.

                                        i am confused what to get!

                                        Steppers often have a supply voltage higher than the supply used, if the driver uses pulse-width-modulation this allows a high-voltage peak to overcome the inductance of the winding is and get better motion. A bit like how PWM control is smoother for slow running on model railways than lowering the driving voltage.

                                        Neil

                                        #271195
                                        Engine Builder
                                        Participant
                                          @enginebuilder
                                          Posted by Neil Wyatt on 11/12/2016 14:17:39:

                                          Posted by Engine Builder on 11/12/2016 14:05:41:

                                          Just been looking for a suitable motor for this project. The one in the article is said to be 24 kg/cm torque but looking at the source metioned I cannot see one with that specification.

                                          I am confused too about the voltage rating of these motors. I assume a 12v is needed as that is the supply voltage.

                                          The one closest to the specified one has a rated voltage of 3v and the one used in the Liming article seems to be 8.6.

                                          i am confused what to get!

                                          Steppers often have a supply voltage higher than the supply used, if the driver uses pulse-width-modulation this allows a high-voltage peak to overcome the inductance of the winding is and get better motion. A bit like how PWM control is smoother for slow running on model railways than lowering the driving voltage.

                                          Neil

                                          It seems the other way around here though. The motors specified have a voltage less than the supply voltage.

                                          #271199
                                          Carl Wilson 4
                                          Participant
                                            @carlwilson4

                                            The rated voltage of the motor will produce the rated current in the windings if applied gradually. we are applying pulses at a fairly rapid rate, so the inductance of the windings tends to prevent the full current building up. So we apply 12 volts to ensure that full current can flow.

                                            The torque of the motor used is near as damn it 2 Nm. 1 kg cm is about 0.09 Nm. So 23 kg cm is roughly 2 Nm.

                                            Edited By Carl Wilson 4 on 11/12/2016 15:12:25

                                            #271200
                                            Neil Wyatt
                                            Moderator
                                              @neilwyatt
                                              Posted by Engine Builder on 11/12/2016 14:30:24:

                                              Posted by Neil Wyatt on 11/12/2016 14:17:39:

                                              Posted by Engine Builder on 11/12/2016 14:05:41:

                                              Just been looking for a suitable motor for this project. The one in the article is said to be 24 kg/cm torque but looking at the source metioned I cannot see one with that specification.

                                              I am confused too about the voltage rating of these motors. I assume a 12v is needed as that is the supply voltage.

                                              The one closest to the specified one has a rated voltage of 3v and the one used in the Liming article seems to be 8.6.

                                              i am confused what to get!

                                              Steppers often have a supply voltage higher than the supply used, if the driver uses pulse-width-modulation this allows a high-voltage peak to overcome the inductance of the winding is and get better motion. A bit like how PWM control is smoother for slow running on model railways than lowering the driving voltage.

                                              Neil

                                              It seems the other way around here though. The motors specified have a voltage less than the supply voltage.

                                              Oops got my description back to front!

                                              Most stepper driver chips limit CURRENT making the actual voltage relatively unimportant, within limits.

                                              #271202
                                              Engine Builder
                                              Participant
                                                @enginebuilder
                                                Posted by Carl Wilson 4 on 11/12/2016 15:08:31:
                                                The rated voltage of the motor will produce the rated current in the windings if applied gradually. we are applying pulses at a fairly rapid rate, so the inductance of the windings tends to prevent the full current building up. So we apply 12 volts to ensure that full current can flow.

                                                The torque of the motor used is near as damn it 2 Nm. 1 kg cm is about 0.09 Nm. So 23 kg cm is roughly 2 Nm.

                                                Edited By Carl Wilson 4 on 11/12/2016 15:12:25

                                                So was it model number SY57STH76-2004A?

                                                #271229
                                                Carl Wilson 4
                                                Participant
                                                  @carlwilson4

                                                  Short answer = Yes, that will do admirably.

                                                  Carl.

                                                  #271389
                                                  Engine Builder
                                                  Participant
                                                    @enginebuilder

                                                    The stepper motor driver arrived today.

                                                    Looking at the connections shown in the magazine article and the original article the wiring diagram was taken from I notice misleading information.

                                                    The article shows the 12v power connected to Arduino terminals gnd and vdd. There is no vdd terminal on the Arduino it is in fact vin.

                                                    The 12v supply to the driver board is shown as gnd and VMot. Again there is no VMot terminal, well not on my board, It should be gnd and +24.

                                                    In the article too there is no mention of what the DIP switches should be set to for stop current, excitation mode and decay setting.

                                                    Just mentioning this in case anyone else is confused.

                                                    #271449
                                                    Bazyle
                                                    Participant
                                                      @bazyle

                                                      Catching up with this it looks like I was well off in assuming it had an interpreter. Good detective work chaps, sorry for misleading you.. If it can work on Linux I must see if I can run the IDE on a Pie then I can play with one at work.

                                                    Viewing 25 posts - 76 through 100 (of 243 total)
                                                    • Please log in to reply to this topic. Registering is free and easy using the links on the menu at the top of this page.

                                                    Advert

                                                    Latest Replies

                                                    Viewing 25 topics - 1 through 25 (of 25 total)
                                                    Viewing 25 topics - 1 through 25 (of 25 total)

                                                    View full reply list.

                                                    Advert

                                                    Newsletter Sign-up