Welcome! Log In Create A New Profile

Advanced

percentage indicator on LCD display on a Prusa. code help.

Posted by macsoft 
percentage indicator on LCD display on a Prusa. code help.
March 06, 2011 01:05PM
So, I got a 2 linex16 chars LCD display connected to my RAMPS, and i got it to work perfectly with some hacking of the tonokip firmaware.
Right now it displays temp on the top line, and on the bottom line, it cycles some more info: feed rate, extruder STU ('cause i can change both in mid print), XYZ positions, and indication when you set them home.

I want to have a Progress percent indicator now. so I can have an ideia of how long to the end of the print.
the best way i found out is to count myself how many lines the generated Gcode has, and i add "L1600" (for 1600 lines) to the code. (The best way would be to get RepSnapper or skeinforge to generate this code line for me, but for now, this works)
This way i hacked firmware so that it counts the lines that are sended and do the math.
glinetotal= is what you get from "L1600" command.
THE CODE:
gline= is the counter for the actual lines sent.
gpercent would be the print progress in percentage.
gpercentint, is int, and its just an easy way to get rid of decimal places of the fload variable.

gpercent = 100*gline/(float)glinetotal;
gpercentint = gpercent;

then i send gpercentint to the display.

This works for a while. but some how, some time after i start print, i start getting a negative number on the display confused smiley
I newbie to C, i've been learning with google. I use to program PICAXES in basic.

Code gurus, what am I doing wrong?

Thanks!
M.
Re: percentage indicator on LCD display on a Prusa. code help.
March 06, 2011 01:50PM
RepSnapper has a progress bar on the upper left of the window right above the display port. Since I'm using Skeinforge to generate g-code, however, it doesn't display the right time.

It sounds like your firmware code is loosing the value for the total number of lines at some point.
Re: percentage indicator on LCD display on a Prusa. code help.
March 06, 2011 02:39PM
yap, repsnapper was a progress bar, but i want to see it on the LCD screen. cant figure out how the firmware looses the count. cause its done to increment the line number as it reads each line confused smiley
Re: percentage indicator on LCD display on a Prusa. code help.
March 06, 2011 02:43PM
You are probably overflowing the value you can store in an int. I guess ints are only 16 bits on an 8 bit Atmel chip so the maximum positive value is 32767.

Try this:

unsigned long gline, glinetotal;

int gpercentint = (int) (100.0 * gline / glinetotal);


[www.hydraraptor.blogspot.com]
Re: percentage indicator on LCD display on a Prusa. code help.
March 06, 2011 04:51PM
heyyy thanks nophead! that did it! i got a functional percentage indicator and progress bar on my LCD smiling smiley
Re: percentage indicator on LCD display on a Prusa. code help.
March 06, 2011 10:18PM
i am eager to see how you added the lcd to the firmware, i also wonder just how many people out there want to add one to there ramps board.

just where did you attach your lcd any how.?


[mike-mack.blogspot.com]
Re: percentage indicator on LCD display on a Prusa. code help.
March 06, 2011 10:31PM
RAMPS leaves arduino mega lots of free pins. if connected it to the pins: 43,41,39,37, 35, 33
so i used arduinos lcd library with thw tonokips firmware.
Basicly you cant print whatever you want on screen. you just gotta pick what you want from the variables used by the firmware, or to create some more.
when i finish my hack i'll post the firmware and instructions on how to connect the lcd.
Re: percentage indicator on LCD display on a Prusa. code help.
March 07, 2011 01:18AM
macsoft Wrote:
-------------------------------------------------------
> when i finish my hack i'll post the firmware and
> instructions on how to connect the lcd.

That would be great. I know I've been wanting to add an lcd for a while.


Help improve the RepRap wiki!
Just click "Edit" in the top-right corner of the page and start typing.
Anyone can edit the wiki!
Sorry, only registered users may post in this forum.

Click here to login