Serin troubles - drift?

demonic-chicken

New Member
Hi,

So, I'm building a robot/appliance which connects to a PC via serial port.
I'm programing on an 18x mounted on a experimenter board, and when I use the serin command to send numbers like 1, 0,2 etc... the 18x records numbers like 50 or 126. Ive used various modes to transmit, and Ive grounded Rcv to 0v via 22k resistor. I added a serout command to confirm what I transmitted, and it confirms by returning my values. Yet when I use debug, or just watch the behavior of the robot, it is still getting numbers in the 50+ range.

I've scoured the forums for a while and found nothing.

any thoughts?

Thanks
 

demonic-chicken

New Member
ooh boy, this is embarrassing.

I examined it a bit more, and found that by values were off by 48.

I was using ascii numbers in math, so it makes perfect senses as to why my counters were off by 48

Don't be like me, I spent all afternoon working on this minor error that crippled my robot.
 

Dippy

Moderator
Yes, think b4 you post eh? Haha. We've all done it, don't worry.

But at least you sussed it and now understand it. Good for you.

So many other people get a little bit stuck and can't be bothered to think. They just post, push off, and let others waste their time. Or just want others to do their school project for them... but that's another story.
 

hippy

Ex-Staff (retired)
Another embarassment will undoubtedly come when you try to input data using -

- SerIn PIN, N4800, (b0)

Not that I've wasted hours on that one, and more than once :) :)

It's usually the case one sees the problem shortly after you've given up all hope and have posted to a forum. It's really writing the problem down that focuses the mind and eventualy reveals the solution. The two best tools you can have while developing and problem solving is (1) going away and doing something else / sleeping on it, and (2) someone who will sit there and let you talk through a problem - even if they don't really understand - it's usually halfway through a sentance that what's wrong becomes blindingly obvious.
 

papaof2

Senior Member
Hippy said "(1) going away and doing something else / sleeping on it, and (2) someone who will sit there and let you talk through a problem - even if they don't really understand - it's usually halfway through a sentance that what's wrong becomes blindingly obvious."

Both certainly work. My mother knew nothing about high school trig, but when I was stuck on a problem she would tell me to explain it to her - worked every time ;-)
When I did "Can this be done?" programming at AT&T, I solved a lot of problems by taking a walk around the block.

John
 

demonic-chicken

New Member
Part of the reason that this took so long is because of the simulation mode in the program editor. When you use Serin in simulation, it takes in data in a different way than in the terminal.

In simulation mode, it required that I enter 6 comma separated characters (in my code), and it interpreted these as numbers.
But in the terminal connecting to my actual hardware, it would take in any ascii and keep them as ascii (initially it took commas too, but i sorted that out).

This lead to alot of confusion as to why worked it perfectly in simulation, and glitched in reality. Has this been brought up before, or do I just not know how to use the terminal/simulation mode?
 
Top