PDA

View Full Version : Hserin



GatorGuy
- 23rd February 2010, 07:21
When using HSERIN, this code seems to receive the data okay but I can only get numbers to work when using if..then statements. I know I am just overlooking something so any help would be great.

This works.....


HSERIN [Inc]
HSEROUT ["Tx Received", 10]
if inc = 1 then goto here
if inc = 2 then goto there


This is what I would like to do.....


HSERIN [Inc]
HSEROUT ["Tx Received", 10]
if inc = "something" then goto here
if inc = "somethingelse" then goto there

aratti
- 23rd February 2010, 07:28
The code below should work.


HSERIN [Inc]
HSEROUT ["Tx Received", 10]
if inc = "something" then goto here
else
goto there
endif



Al.

GatorGuy
- 23rd February 2010, 07:47
I tired that, it gets bad expression errors on the if inc = "something" line.

aratti
- 23rd February 2010, 08:09
I tired that, it gets bad expression errors on the if inc = "something" line

"something" must be replaced with an ascii character or its decimal equivalent.

For instance:



HSERIN [Inc]
HSEROUT ["Tx Received", 10]
if inc = "S" then goto here
else
goto there
endif


If you Tx the letter "S" then your progam will jump to label "here" and execute the code in it, else it will jump to the label "there" and execute a different code. (if you make it different)

You have to fix which ascii character you will send to go to label "here" since any other ascii character will take to label "there"

Al.

GatorGuy
- 23rd February 2010, 08:17
When I use single letters or numbers it works like a charm but I would like to use longer strings such as "A23". Anything longer then one character and I get errors. Is this a limitation of picbasic?

Acetronics2
- 23rd February 2010, 08:32
Hi,

I think the answer simply is in your Manual ... HSerin Modifiers section.

Alain

Charles Linquis
- 23rd February 2010, 14:04
The following is a technique that I got from Darrel Taylor. It will input a string, and search it for any number of strings.

Note that the "timeout" in the ArrayRead command is the number of characters in the string you are looking for during that pass.





HSERIN2 300,InputTimeout,[Str CharArray\12\10] ; Take in max 12 chars optionally terminated by LF.

ARRAYREAD CharArray,19,FailedFirst,[WAIT ("FirstStringToLookFor")]
Goto FoundFirstItem

FailedFirst:
ARRAYREAD CharArray,21,FailedSecond,[WAIT (SecondStringToLookFor")]
Goto FoundSecondItem

FailedSecond:

Charles Linquis
- 23rd February 2010, 16:28
I should always learn to read my text before hitting SUBMIT. In the example, I have it inputting only 12 chars, while it is testing for a substring of 19 or 21 chars - but you get the idea.

GatorGuy
- 25th February 2010, 09:59
Thank you! I will give this a try.

Acetronics2
- 25th February 2010, 10:07
Hi, Gator

Did your pic decided to start ???

http://www.electro-tech-online.com/micro-controllers/104019-pic-not-running-anything.html

BTW, here is the best place to ask about PBP programs ...

Alain

GatorGuy
- 26th February 2010, 10:38
Not yet, it turned out to be a programmer error that I wasn't catching. At first it was giving a valid program response then I noticed that it still had an old program on the pic I was using. Building a new programmer today. Its ready to etch now, just waiting 'til morning to finish it.

And yes, picbasic has been the greatest thing since the pic came out! I can't stand programming with asm.

Acetronics2
- 26th February 2010, 12:36
Hi,

Why have trouble with doubtful programmers ...

look at the Pickit 2 ( or 3 ) price !!!

add the universal programmer module ( ~ 30 US$ ? ) and you have one of the bests programming tools available ...

...

Alain