Notifications
Clear all

Road block LCD issue DB1

Page 1 / 3

mrclassicman
(@mrclassicman)
Active Member
Joined: 2 weeks ago
Posts: 14
Topic starter  

Sorry, I am a late starter to this project and have run into an issue in which I would appreciate some assistance, if possible. I am not able to get any responses from the LCD display other than the initial display of: "PWM:0 and DIR:0".  If I press the reset button the motor cycles for 200ms at full speed then stops. None of the other buttons have any effect what so ever. My diagnostics to this point have included  running the LCD_Key example grab key, and this did work , caveat, I had to turn up the contrast to the max and there is some flickering in the display. I also entered in the code manually and rechecked it line by line for accuracy. The code loads and compiles without issues. I feel I am missing something very basic, but at this point I have no clue as to what that is! Any direction or insight would be greatly appreciated.

Terry


Quote
codecage
(@codecage)
Member Admin
Joined: 2 years ago
Posts: 1106
 

@mrclassicman,

Not a lot to go on here in order to offer you some assistance.  Maybe provide some more detail.  

Posted by: @mrclassicman

I am not able to get any responses from the LCD display other than the initial display of: "PWM:0 and DIR:0".  If I press the reset button the motor cycles for 200ms at full speed then stops. None of the other buttons have any effect what so ever.

What are we trying to do here and what is the equipment setup.  Maybe I'm the one being dense here, but see if you can help me understand what you are trying to accomplish.

SteveG


ReplyQuote
Will
 Will
(@will)
Prominent Member
Joined: 5 months ago
Posts: 817
 
@mrclassicman
 
Welcome to the forum.
 
Posted by: @mrclassicman

Sorry, I am a late starter to this project and have run into an issue in which I would appreciate some assistance, if possible. I am not able to get any responses from the LCD display other than the initial display of: "PWM:0 and DIR:0".  If I press the reset button the motor cycles for 200ms at full speed then stops.

OK, so the reset button appears to work. Is that what you expected it to do ?

None of the other buttons have any effect what so ever.

Add Serial.print statements into your sketch and see if those code sections are being executed. If not, verify that your wring matches the button's logic (that is, button tied HIGH and test for button down tests for LOW or vice versa.

My diagnostics to this point have included  running the LCD_Key example grab key, and this did work , caveat, I had to turn up the contrast to the max and there is some flickering in the display. I also entered in the code manually and rechecked it line by line for accuracy. The code loads and compiles without issues. I feel I am missing something very basic, but at this point I have no clue as to what that is! Any direction or insight would be greatly appreciated.

If you are really certain that the sketch is golden, then the problem is most likely a faulty part, or faulty wiring. If you needed to turn the LCD up the whole way then you may have a bad solder joint or two.

It may help to remove the power from your circuit, take a multimeter set for continuity and verify that all your expected VCC are connected and GND points are connected.

Then return the power to the circuit and carefully retest that there is power where expected and ground where expected.


ReplyQuote
robotBuilder
(@robotbuilder)
Noble Member
Joined: 2 years ago
Posts: 1004
 

@mrclassicman

I'd like to include a pic, but as this is my first post, I'm not allowed.

When can you post a pic?

Without sufficient information (the actual code and the actual hardware with wiring schematic) it is impossible to help with a problem without a long winded exchange of posts playing guess what it might be game.

If you use the Arduino IDE then a way to post nice code is right mouse click on text, Select All, right mouse click on the text again and Copy as HTML.
Then go to your post and hit the CRLF (RETURN OR ENTER KEY) a number of time where you want to insert the code. Click in the top bar {;} which is the insert code button. Right mouse button click between a

and a

and Paste.

For schematics or images the bottom bar has a paper clip symbol and Attach Files to click.

 

 

 

 

This post was modified 2 weeks ago by robotBuilder

ReplyQuote
mrclassicman
(@mrclassicman)
Active Member
Joined: 2 weeks ago
Posts: 14
Topic starter  

First thanks for the responses, I appreciate the input. I will try and send copy of the sketch when I get back in the shop. Has anyone here that responded actually tried building this DB! from the beginning? I do figure that I am missing something very basic and fundamental. When I find it I will probably be very embarrassed! lol

Terry


ReplyQuote
Will
 Will
(@will)
Prominent Member
Joined: 5 months ago
Posts: 817
 

@mrclassicman

Don't worry about making mistakes. Anyone who has never made a mistake has never made anything. Besides, you rarely learn anything doing it right the first time, you really learn by trying to figure out what went wrong and how to fix it 🙂

BTW - I have not built this project.


ReplyQuote
mrclassicman
(@mrclassicman)
Active Member
Joined: 2 weeks ago
Posts: 14
Topic starter  

Here is the code that I have entered , compiled and loaded into the Arduino Uno. To save typing some comments have been left out. The buttons defined do not initiate any change in the LCD display or in the output from the Arduino to the MC10 r3 controller. It is my belief that the once I get the proper response from the LCD (communication) to the device will also fall in line. I am not even bothering to wire the controller to the unit till this hurdle is over come. Just a note, the MC10 controller has self test buttons which allow me to test the motor and connections. These work and the motor can be started, stopped and direction changed. so again I am firm in the belief that the core issue is with the LCD/Arduino sketch. With this I also acknowledge that I may be the leading factor to this disfunction. lol

//dronebot work shop 2019
// https://dronebotworkshop.com

//include libraries
#include <LiquidCrystal.h>
#include <LCD_Key.h>

// Define keycodes
#define None 0
#define Select 1
#define Left 2
#define Up 3
#define Down 4
#define Right 5

// Pin for analog key pad
#define diy_pwm A2
#define pwm 3
#define dir 2

// Define LCD connections
LiquidCrystal lcd (8, 9, 4, 5, 6, 7);
// setup object keypad
LCD_Key keypad;

// variable for pwm signal
int pwm_value = 0;

//variable for keypad
int localKey;

void setup() {
// setup LCD
lcd.begin(16, 2);
lcd.clear();

//set pwm frequency
setPwmFrequency(pwm, 8);

// define pins
pinMode(pwm, OUTPUT);
pinMode(dir, OUTPUT);
}

void loop()
{
while(1)
{
//scan keypad for entry
localKey = keypad.getKey();

// toggle motor direction if left button was pressed
if(localKey == Left){
digitalWrite(dir,!digitalRead(dir));
delay(200);}

// increase motor speed up button
if(localKey==Up){
pwm_value++;
delay(200);
lcd.clear();}

//decrease motor speed button down
else if(localKey==Down){
pwm_value--;
delay(200);
lcd.clear();}

//limit PWM range
if(pwm_value>255)
pwm_value= 255;
else if(pwm_value<0)
pwm_value = 0;

// send output to pin
analogWrite(pwm,pwm_value);

//print to LCD
lcd.setCursor(0,0);
lcd.print("PWM:");
lcd.print(pwm_value);
lcd.setCursor(0,1);
lcd.print("DIR:");
lcd.print(digitalRead(dir));
}
}
void setPwmFrequency(int pin, int divisor){
byte mode;
if(pin == 5|| pin == 6 || pin == 9 || pin == 10) {
switch(divisor) {
case 1:mode = 0x01; break;
case 8:mode = 0x02; break;
case 64:mode = 0x03; break;
case 256:mode = 0x04; break;
case 1024:mode = 0x05; break;
default: return;
}
if(pin == 5 || pin == 6) {
TCCR0B = TCCR0B & 0b11111000 | mode;
} else {
TCCR1B = TCCR1B & 0b11111000 | mode;
}
}else if(pin == 3 || pin == 11) {
switch(divisor) {
case 1: mode = 0x01; break;
case 8: mode = 0x02; break;
case 32: mode = 0x03; break;
case 64: mode = 0x04; break;
case 128: mode = 0x05; break;
case 256: mode = 0x06; break;
case 1024: mode = 0x07; break;
default: return;
}
TCCR2B = TCCR2B & 0b11111000 | mode;
}
}

 

 


ReplyQuote
robotBuilder
(@robotbuilder)
Noble Member
Joined: 2 years ago
Posts: 1004
 

 tried to work out the indents,

 

 

//dronebot work shop 2019
// 

//include libraries
#include <LiquidCrystal.h>
#include <LCD_Key.h>

// Define keycodes
#define None 0
#define Select 1
#define Left 2
#define Up 3
#define Down 4
#define Right 5

// Pin for analog key pad
#define diy_pwm A2
#define pwm 3
#define dir 2

// Define LCD connections
LiquidCrystal lcd (8, 9, 4, 5, 6, 7);
// setup object keypad
LCD_Key keypad;

// variable for pwm signal
int pwm_value = 0;

//variable for keypad
int localKey;

void setup() {
  // setup LCD
  lcd.begin(16, 2);
  lcd.clear();

  //set pwm frequency
  setPwmFrequency(pwm, 8);

  // define pins
  pinMode(pwm, OUTPUT);
  pinMode(dir, OUTPUT);
}

void loop(){
  while(1)
  {
    //scan keypad for entry
    localKey = keypad.getKey();

    // toggle motor direction if left button was pressed
    if(localKey == Left){
      digitalWrite(dir,!digitalRead(dir));
      delay(200);
    }

    // increase motor speed up button
    if(localKey==Up)
    {
      pwm_value++;
      delay(200);
      lcd.clear();
    }

      //decrease motor speed button down
    else if(localKey==Down){
      pwm_value--;
      delay(200);
      lcd.clear();
    }

    //limit PWM range
    if(pwm_value>255)
      pwm_value= 255;
    else if(pwm_value<0)
      pwm_value = 0;

    // send output to pin
    analogWrite(pwm,pwm_value);

    //print to LCD
    lcd.setCursor(0,0);
    lcd.print("PWM:");
    lcd.print(pwm_value);
    lcd.setCursor(0,1);
    lcd.print("DIR:");
    lcd.print(digitalRead(dir));
  }
}

void setPwmFrequency(int pin, int divisor){
  byte mode;
  if(pin == 5|| pin == 6 || pin == 9 || pin == 10) {
    switch(divisor) {
    case 1:mode = 0x01; break;
    case 8:mode = 0x02; break;
    case 64:mode = 0x03; break;
    case 256:mode = 0x04; break;
    case 1024:mode = 0x05; break;
    default: return;
  }
  
  if(pin == 5 || pin == 6) {
    TCCR0B = TCCR0B & 0b11111000 | mode;
  } else {
    TCCR1B = TCCR1B & 0b11111000 | mode;
  }
  }else if (pin == 3 || pin == 11) {
    switch(divisor) {
      case 1: mode = 0x01; break;
      case 8: mode = 0x02; break;
      case 32: mode = 0x03; break;
      case 64: mode = 0x04; break;
      case 128: mode = 0x05; break;
      case 256: mode = 0x06; break;
      case 1024: mode = 0x07; break;
      default: return;
    }
    TCCR2B = TCCR2B & 0b11111000 | mode;
  }
}

 

 


ReplyQuote
Will
 Will
(@will)
Prominent Member
Joined: 5 months ago
Posts: 817
 
Posted by: @mrclassicman

Here is the code that I have entered , compiled and loaded into the Arduino Uno. To save typing some comments have been left out.

Don't type it, give yourself a break and copy'n'paste it in. Select the whole sketch on the Arduino,  click "copy as HTML" then move to your browser to the DBWS reply. Hit the carriage return a couple of times and then click the "{;}" icon at the top of the reply box, move between a "<P>" and a "</P>" and paste.

The buttons defined do not initiate any change in the LCD display or in the output from the Arduino to the MC10 r3 controller. It is my belief that the once I get the proper response from the LCD (communication) to the device will also fall in line.

[snipt]

so again I am firm in the belief that the core issue is with the LCD/Arduino sketch. With this I also acknowledge that I may be the leading factor to this disfunction. lol

//dronebot work shop 2019
// https://dronebotworkshop.com

//include libraries
#include <LiquidCrystal.h>
#include <LCD_Key.h>

[rest of sketch removed for brevity]

Where did you get the LCD_Key include CPP and H files ? They don't seem to match up with the usual LCD keypad object definition (such as arduino-display-lcdkeypad).


ReplyQuote
mrclassicman
(@mrclassicman)
Active Member
Joined: 2 weeks ago
Posts: 14
Topic starter  

 Those libraries were included in a Zip file at the end of the first segment of the DB1 project. I type in the code as it helps me build a structure of syntax in my mind. Eventually it will help me see issues before they are issues as well as help me structure my own code when I start coding myself. I do pretty well modifying code to do or make things work better for me. It also gives me a little better understanding of how things integrate with each other. as Edison was quoted as having said " I now know a thousand ways of hownot to make a light bulb!", or something like that. I do not know if this is a significant item or not but the LiquidCrystal.h library  shows up in a light blue color when entered correctly. The LCD_Key.h library does not show any color just black. Usually "happy" code words show up as a color. Could this indicate a problem with the library installation?

Terry


ReplyQuote
mrclassicman
(@mrclassicman)
Active Member
Joined: 2 weeks ago
Posts: 14
Topic starter  

@robotbuilder ? how can I copy the code you placed in your reply? I can't seem to isolate it and end up getting all the pages and responses. Or just to print it?


ReplyQuote
robotBuilder
(@robotbuilder)
Noble Member
Joined: 2 years ago
Posts: 1004
 

@mrclassicman 

The LCD_Key.h library does not show any color just black. Usually "happy" code words show up as a color. Could this indicate a problem with the library installation?

Unlikely the library, more likely the hardware. You can adjust the display with two POTS as shown in the example I posted some time ago when working on someone's sonar problem.
https://forum.dronebotworkshop.com/hobbies/water-level-indicator/paged/2/#post-11288

 how can I copy the code you placed in your reply? I can't seem to isolate it and end up getting all the pages and responses. Or just to print it?

Will explained in a post back as did I,
If you are using the Arduino IDE you right mouse click the text and Select All, you then right mouse click again and select Save as HTML. Then you go to your post in this forum and hit the Enter key a few times to make some space. Then select the {;} button in the top bar of the post. Now you will see pairs of  P's  right click between a pair and Paste.

 

This post was modified 2 weeks ago 2 times by robotBuilder

ReplyQuote
Will
 Will
(@will)
Prominent Member
Joined: 5 months ago
Posts: 817
 

@mrclassicman 

Your code may compile cleanly but it has some unusual parts.

1) why are you using a "while(1)" loop inside a C++ method that just loops anyway ?

2) why does the "void setPwmFrequency(int pin, int divisor)" have a case statement for the "pin" argument when the only possible value will be 3 ?

3) does it not seem confusing to have to push the "left" key to go right ?

4) I suggested the you add some Serial.print statements to check on the execution. You haven't said anything to suggest that you'd done so. Please add "Serial.begin(9600);" (or whatever baud rate you're using) for your setup() method and add 'Serial.print("localKey = "); Serial.println(localKey);' to the sketch immediately following the assignment of localKey.

No point in looking any deeper if the key isn't being interpreted correctly.


ReplyQuote
mrclassicman
(@mrclassicman)
Active Member
Joined: 2 weeks ago
Posts: 14
Topic starter  

Thank you for the input and I will implement your suggestions. The code is not mine so I cannot answer to its structure. I am well below the ability to code at this level. The code has been taken from dronebotworkshop.com Arduino, controlling large DC gear motors. The first half of the program sets up pulse width modulation for controlling the MD10C, as well as the LCD display, the second half was to configure the frequency that the pulse width was sent. This was done after Bill did some experimentation to improve efficiency. Ultimately this LCD will not even be used, it is only for my ability to test the function of the drives and will eventually be replaced with radio control. The big issue may just be that the LCD shield I am using does not mimic exactly the one that Bill used. I started by thinking that this would be a simple easily diagnosed issue that someone may have already solved. Obviously, this is not the case. I will include your suggested code for the serial monitor and print statements as this may just narrow down the search. Thank you very much for your assistance.

 

Terry


ReplyQuote
robotBuilder
(@robotbuilder)
Noble Member
Joined: 2 years ago
Posts: 1004
 

@mrclassicman 

Now knowing the source of the code and the project helps understand what you are doing.

https://dronebotworkshop.com/dc-gearmotors-pwm/

I unzipped the download but am having trouble in that I still get the error.
exit status 1
LCD_Key.h: No such file or directory

If anyone can explain the steps required for this to be found by the compiler would interest me?

To enlarge image right click image and Open Link in new window.

unzipped

I would love to work this one out but don't have the actual hardware myself to test.

Have you the exact same hardware wired up the exact same way?

 

This post was modified 2 weeks ago by robotBuilder

ReplyQuote
Page 1 / 3