Author Topic: 44780 + webbotlib problems  (Read 2117 times)

0 Members and 1 Guest are viewing this topic.

Offline totalisTopic starter

  • Full Member
  • ***
  • Posts: 89
  • Helpful? 0
44780 + webbotlib problems
« on: June 29, 2011, 03:53:43 PM »
This is the code i am trying to use on my ATMEGA328P, i have an LED on B0, this is so i can tell what the state of the program is.  It is setup to turn on when the displayInit has run.  what actually happens is the LED flickers; even when the LCD is not connected. I assume that the LED flickering means the microcontroller is constantly resetting.

i can recompile with a blank initHardware (etc.) and it still happens, this suggested that the function displayInit is to blame, and when i comment out this function, the LED's are on constantly.

I am using webbot 1.31 and a standard 44780 2x16, I am trying to use 4 bit mode


Help.

T

Code: [Select]
#include "sys/atmega328P.h" //These are the includes required by the webbotlib library.
#include "a2d.h"
#include "iopin.h"
//#include "uart.h"
#include "rprintf.h"
#include "Displays/Generic/HD44780.h"

// Forward reference
MAKE_WRITER(display_put_char);
// Define the display for the Axon
HD44780 display = MAKE_HD44780_4PIN(16,2,D0,D1,D2,D3,D4,D5,D6,&display_put_char);
// Create a Writer to write to display
MAKE_WRITER(display_put_char){
    return displaySendByte(&display,byte);
}


void appInitHardware(void) // In my initialising code
{
pin_make_output(B0,FALSE);
displayInit(&display);
        pin_low(B0);
    setErrorLog(displayGetWriter(&display));
    rprintfInit(displayGetWriter(&display));
}

TICK_COUNT appInitSoftware(TICK_COUNT loopStart)//This is the main loop that provides timing by delaying by 1 cycle
{
    displayAutoScroll(&display,FALSE);
    displayLineWrap(&display,FALSE);
 
    int cols = MIN(NUM_ADC_CHANNELS, displayColumns(&display));
    for(int n=0; n<cols;n++){
        rprintf("%d",n % 10);
    }
    return 0;
}
 
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) {
int depth = displayLines(&display)-1;
    int cols = MIN(NUM_ADC_CHANNELS, displayColumns(&display));
    for(int ch = 0; ch<cols; ch++){
        uint8_t val = a2dConvert8bit(ADC_NUMBER_TO_CHANNEL(ch));
        displayVertGraph(&display,ch,1, val, 255, depth);
    }

    return 10;
}

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: 44780 + webbotlib problems
« Reply #1 on: June 29, 2011, 04:52:08 PM »
Quote
I assume that the LED flickering means the microcontroller is constantly resetting.
How does your battery voltages look?

Offline totalisTopic starter

  • Full Member
  • ***
  • Posts: 89
  • Helpful? 0
Re: 44780 + webbotlib problems
« Reply #2 on: June 29, 2011, 05:23:22 PM »
They are at a very stable 5v, i havent used a scope on them but the DMM says 5.01v (Very luck on the vreg i suppose), The result is the same even without the device connected and so i think its down to software. On a few occasions, the LED will stay on, meaning i think the program is running; at this time i measured the voltages on the control pins: RS 5v , RW 5v, E 2.34v
this makes me think the E pin is cycling very quickly between 5v and 0v giving an average of 2.34v

i havent checked the other pins, the cap on the 5v side is 1000uf so the device should not reset as a result of large power drain (as easily)

T

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: 44780 + webbotlib problems
« Reply #3 on: June 29, 2011, 05:35:00 PM »
If you comment out this one line:
displayVertGraph(&display,ch,1, val, 255, depth);
does it still reset?

Offline totalisTopic starter

  • Full Member
  • ***
  • Posts: 89
  • Helpful? 0
Re: 44780 + webbotlib problems
« Reply #4 on: June 29, 2011, 05:44:59 PM »
I don't know specifically, I will try it. What should the expected voltages at the pins be?

T

Offline totalisTopic starter

  • Full Member
  • ***
  • Posts: 89
  • Helpful? 0
Re: 44780 + webbotlib problems
« Reply #5 on: June 29, 2011, 05:47:15 PM »
I have commented out all display related things (except the init) and it still does it...

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: 44780 + webbotlib problems
« Reply #6 on: June 29, 2011, 05:50:43 PM »
I have commented out all display related things (except the init) and it still does it...
Comment out the init of the display, too, and see if it still resets.

If it still resets, disconnect the display from your microcontroller and see what happens.

Offline totalisTopic starter

  • Full Member
  • ***
  • Posts: 89
  • Helpful? 0
Re: 44780 + webbotlib problems
« Reply #7 on: June 29, 2011, 05:55:09 PM »
It makes no difference if the display is connected or not, but when I comment the init command the LED lights properly. I have tried this on 2 different but identical microcontrollers.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: 44780 + webbotlib problems
« Reply #8 on: July 01, 2011, 10:50:13 AM »
In your appInitSoftware you could send a msg like 'Booting up' and return a delay like 5000000 (ie 5 seconds).
This means your display will tell you if there is a reset happening or not.

The other alternative is whether there is some kind of short between B0 and one of the pins used by the display (intentional or not). Is this a homemade board or a commercial one in which case what is it. Then we can check the schematic.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline totalisTopic starter

  • Full Member
  • ***
  • Posts: 89
  • Helpful? 0
Re: 44780 + webbotlib problems
« Reply #9 on: July 03, 2011, 10:25:37 AM »
Wow that's a good idea! That's why this forum is wonderful. I am using a custom made MCU, I made a thread on it recently (in misc) with pics etc if you want the schematic I will upload later. I am not infront of my electronics so I will test this out later on, I will also check the resistance between rs, rw, e and the other pins. I did solder the pins onto the 44780 board myself so I could have shorted something... it is strange that the unit still rests without the display plugged in....

Thanks guys

T

 


data_list