Forum

Welcome Guest 

Show/Hide Header

Welcome Guest, posting in this forum requires registration.





Pages: [1]
Author Topic: Positioning problems when drawings start
mbcook
Newbie
Posts: 11
Permalink
Post Positioning problems when drawings start
on: August 4, 2012, 01:38
Quote

I received my Polargraph SD kit last week and got it running last weekend, and I've been experimenting with it. Right now it's running the latest controller and firmware (those release earlier today), although I've had this problem the entire time.

The Polargraph moves around just fine. I position the gondola over the home point, hit "set home", and things work as I expect. I can jog the machine around using "move pen to point" and "move direct" and the machine moves right to that point. I've got all the measurements correct.

The problem I'm having is when drawing things. I've made one or two drawings successfully, so this isn't always happening. I don't know what I'm doing that triggers this (I assume I'm involved).

So the machine will at the home point. When it starts running the code to render a drawing (well positioned), the gondola swings over from the home point to the top right of the picture, as I would expect. In my successful drawings it works correctly from there.

When the problem occurs, instead of moving around a bit to start drawing lines, both motors retract. It's acting as if the gondola was at the bottom of the machine and had to be lifted a long distance. If I lift the cord off the spools and let it finish the move, it seems to get to a point where it's happy and then continue on from there as normal.

The machine is 514x850mm, paper is 217x280mm. Home point is at 257,120. Top of the paper is centered there. Step multiplier is 8, 95mm/rev, 400 steps/rev.

The commands being run start out like this:

C02,1.0,END
C31,600.0,END
C32,400.0,END
C09,1238,1238,END
C08,2,2,END
C01,1573,1184,END
C13,END
C05,1591,1184,37,255,END

The home point (1238, 1238) is correct. The start point (1573, 1184) is also the correct top-right corner of the drawing. The machine seems to think it's somewhere else (despite the C09 home command).

I just discovered the console after the last time this happened, so I haven't watched that to see if there is anything informative there.

Any ideas what this might be, or how I might go about figuring it out?

Thanks for any help.

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Positioning problems when drawings start
on: August 4, 2012, 10:16
Quote

When this happens to me, the gondola shoots off in the wrong direction, and judders around at top making awful noises, and it's generally because I've forgotten to set home.

If it works sometimes then I guess the configuration is loaded correctly, but you can check by looking at the console when the board resets, also the touchscreen shows the settings for a second too.

Is it only interactively when it happens, or only when working from SD?

If you run that little set of commands, does it ever do it?

cheers!
sn

mbcook
Newbie
Posts: 11
Permalink
Post Re: Positioning problems when drawings start
on: August 4, 2012, 20:26
Quote

I've had it happen both interactively and running from the SD. I've been putting the "set home" command in the files that I put on the SD card so even running from SD the machine should be in a known position. I'll keep experimenting now that I've got some time.

mbcook
Newbie
Posts: 11
Permalink
Post Re: Positioning problems when drawings start
on: August 4, 2012, 20:59
Quote

OK, here is the file I'm using. It's a simple variable frequency drawing of a gameboy.

http://pastebin.com/xy11rECN

Here is the log from trying to run it. This is after a clean start:

http://pastebin.com/PiQS45WH

I start things up, turn on the motor, load the file, reload the file (because I accidentally erased a line in the queue), then start the queue going. When the board executes the first C05 is when the problem occurs. After that line finishes, it moves around as it normally would (assuming it was positioned correctly).

So I modified the firmware to re-enable the debug printouts on the C05 command, and produced this run:

http://pastebin.com/LiAymr24

The debug output lists sane points (1574,1184 and 1609, 1184).

But both runs show lines like "SYNC,196,148,END" right after that C5, which means the bot has it's position out of whack, right? That would explain why the motors both reel in so much if they think they have to take in more than 1000 steps.

My immediate programmer suspense is an overflow. I'm going to dig around and put/enable more debug code to try to figure out what's going on.

mbcook
Newbie
Posts: 11
Permalink
Post Re: Positioning problems when drawings start
on: August 4, 2012, 21:35
Quote

OK, here's a bit more. I added code to print out all the variables involved in the drawSquarePixel function. It doesn't look like anything is being lost converting ints to longs to float, etc.

http://pastebin.com/Rx6SbYwN

So I tried again with printouts to dump state of the motors.

http://pastebin.com/hyGEbb4V

It clearly thinks it needs to move a very long distance (shown by the distance to go numbers). I haven't read any of that code so I don't know why it thinks that (or if that seems correct). Given the scale factor of 8, I believe the raw position it thinks it's starting in should be correct. That's going to have to be the end of this debugging session for now.

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Positioning problems when drawings start
on: August 4, 2012, 23:45
Quote

Thanks for that - very good stuff. I think it's heading up to a non-multiplied position. So it's going from your last good position:
C05,1591,1184,37,255,END

(which seems reasonable)
and next pops up, reporting that it's managed to make its way to SYNC,196,148,END

And I suppose its no mistake that 196,148 x 8 is 1568,1184 which is on the same row as the requested pixel. There's a value slipping through that's not being multiplier()'d.

Thanks for looking closer into this - I appreciate such good diagnostics!
***
after a quick look a the code, I guess this is because of the first couple of lines in the pixel file:

void pixel_drawSquarePixel()
{
long originA = asLong(inParam1);
long originB = asLong(inParam2);
int size = asInt(inParam3);
int density = asInt(inParam4);
...

All parameters coming in from outside are interpreted through the asLong(inParamX), asInt(inParamX) (etc) functions, and all native-coordinate instructions should also have multiplier(...) on them.

So those lines should be:
long originA = multiplier(asLong(inParam1));
long originB = multiplier(asLong(inParam2));

Pixel size should probably be multiplied too, though I think it's a matter of taste. I'm working myself up to metricking this size out to be an absolute value specified in mm (rather than steps), but that's for another day. For now it's steps:
int size = multiplier(asInt(inParam3));

But density is a number between 0-255, so no multiplying for it:
int density = asInt(inParam4); // same as it ever was

I'm not that surprised by this coming up actually, this is a fairly radical restructure of the codebase. I will have a closer look tomorrow.

Good night!
sandy noble

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Positioning problems when drawings start
on: August 5, 2012, 22:16
Quote

Right, that was one problem in the code, actually none of the pixel_ commands were multiplied properly. And another thing, page size was being calculated in the wrong place, so half of the move direct type commands weren't working either. And drawing from file. And a couple of other things.

So. Maybe I should have tested it a bit more. Not saying that this is the last of the problems, but in the long run this new arrangement of files is much better, and it's already a lot more readable / navigable this way. I think anyway!

sn

mbcook
Newbie
Posts: 11
Permalink
Post Re: Positioning problems when drawings start
on: August 6, 2012, 01:31
Quote

Checked out the latest version (r340), and it's fixed. The machine is successfully drawing, and didn't try to reel in a few extra feet of cord at the start.

Glad I could help. Splitting up the code makes perfect sense to me. It would have been large to begin with, but considering you have at least three different versions of the firmware to build I'm surprised you didn't do it earlier.

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Positioning problems when drawings start
on: August 6, 2012, 09:54
Quote

Tell me about it. I was going down the route of making up a kind of abstracted library for it, but that proved to be not as straightforward as I'd hoped, and all the new development has been more-or-less limited to the polarshield branch anyway so it hasn't been too much of a problem.

The issues you guys have been bumping into are because of the collision between the older code and the newer code - the stuff I'd forgotten that I'd added or changed mostly.

sn

kongorilla
Pro
Posts: 362
Permalink
kongorilla
Post Re: Positioning problems when drawings start
on: August 6, 2012, 20:56
Quote

I'm going a little bonkers. I've tried using the latest bundle, and directly getting source for r340. My gondola is still shooting north at the first pixel, and roving commands never seem to happen. Since mbcook is having success, I'm wondering where I'm going wrong.
****STOP THE PRESSES****
I just tried uploading the r340 hex, and normal polargraph drawing now works. Roving stuff still isn't roving.

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Positioning problems when drawings start
on: August 6, 2012, 23:44
Quote

Hm! Does it say anything in the console as a response to your roving commands?

sn

kongorilla
Pro
Posts: 362
Permalink
kongorilla
Post Re: Positioning problems when drawings start
on: August 7, 2012, 00:15
Quote

I've got it sussed. The filename of the image I was trying to render was toothless.pbm. Sending that filename resulted in a console message like "that file can't be found". I checked on the touchscreen, and the file was listed as tooth~2.pbm. I tried sending that as well, but it didn't work. I changed the filename to abc.pbm, and it worked fine. Typing the name abc closed the console, though - woops!
Short filenames FTW!

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Positioning problems when drawings start
on: August 7, 2012, 09:34
Quote

I know I forgot how hard to it was to make filenames that make sense with those short 8.3 filenames. The glory days of DOS were rubbish. Ah, and the console and the info screen pop up when you type c or i I know, that's annoying too! All in all, this has been a very annoying update! Did you get it running eventually?

Mbcook alerted me to a file format issue that might spring up for GIMP users, but has (very) helpfully (thank you) also supplied a patch to fix it - it looks like the PBM format isn't quite as simple as I first thought (why would it be). I will roll his fix into the code next chance I get.

sn

kongorilla
Pro
Posts: 362
Permalink
kongorilla
Post Re: Positioning problems when drawings start
on: August 7, 2012, 10:37
Quote

Yeah, I got it to work -- did a very nice norwegian render. And I figured out why my update didn't work until I used the hex (it was nothing you need to worry about).

I don't think I've used a pbm in twenty years...*oh god*...maybe more...I think a dial-up BBS was involved. I AM OLD.

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Positioning problems when drawings start
on: August 7, 2012, 11:25
Quote

It's not a competition! I'd actually forgotten that pbm was the same pbm I used to know. I picked it off the shelf because it was so easy to parse. I'm having flashbacks to deluxe paint 2.

kongorilla
Pro
Posts: 362
Permalink
kongorilla
Post Re: Positioning problems when drawings start
on: August 7, 2012, 20:11
Quote

Well, if it were a competition, I'd tell you I actually know the guy who made deluxe paint II, DOS, that's how old I am. Well, I've met him a few times, anyway. I was a game artist who worked with his wife back in the day.

Sorry. Back on topic from now on, I promise.

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Positioning problems when drawings start
on: August 7, 2012, 21:01
Quote

Deluxe paint 2 was the king. I am proper jel.

Pages: [1]
Mingle Forum by cartpauj
Version: 1.0.34 ; Page loaded in: 0.039 seconds.