20X2 serin timeout not work!

Vroom

Member
I've made a code for security monitor home. serin received a data its working well, but something is not work when press switch input portB not response while wait serin timeout 200mS. Serin haven't timeout for next address is press! I edited copy and paste show here;


main:
serin [200,press], 2, N2400, ("vs"), b9
if b9=1 then knock
if b9=2 then calling
if b9=3 then mailbox
if b9=4 then window1
...
...
...
...
...
...
goto main

press:
if pinB.7 = 1 then resets
if pinB.4 = 1 then checks
goto main

Is there code something is not right?
 

Dippy

Moderator
welcome back Vroom / Vroom8.
What happened to Vroom 1 to 7? :rolleyes:

I'm not sure if I understand you correctly, but are you askiing why it doesn't respond to button presses during the 200mS wait time?

If so, then remember there is no hardware buffering, so just hold the button for longer and use a until-button-released loop in your press subroutine.

If not, then sorry, I really can't follow what you are attempting to say.
Though, when testing things like this I would temporarily put in a much longer timeout time to check and test your observations.


Maybe restate the question in your first language then someone can translate. (I think we tried this before without success, but it's worth another try). Pleae don't erase the post as someone may know exactly what you are saying.
 
Last edited:
welcome back Vroom / Vroom8.
Maybe restate the question in your first language then someone can translate. (I think we tried this before without success, but it's worth another try). Pleae don't erase the post as someone may know exactly what you are saying.
Please try posting in your language, some of us are multilingual and could help clarify your question.
 
Last edited:

Chavaquiah

Senior Member
I think you're expecting serin to exit (timeout) if a button is pressed. That's not how it works. Timeout is the time serin will wait for until a valid serial signal is received.

With a 20X2, perhaps you could use hsersetup to accept serial communications in the background.
 

Vroom

Member
Sure, I will ask someone can translate first for my language before put in Posts, make bright them to understand, who sorry let you Dippy down as were a bit afraid and avoid there blame, then realized that. Ok, wont erase the Post. Sir.

Right, I will read manual about hsersetup somehow timeout, thanks.
 

inglewoodpete

Senior Member
First, try long time out value: 5 seconds.
Also, receive b9 as a character.
Code:
serin [[COLOR="Red"]5000[/COLOR],press], 2, N2400, ("vs"), [COLOR="red"]#b9[/COLOR]
if b9=[COLOR="red"]"1"[/COLOR] then knock       'Receive "vs1"
if b9=[COLOR="red"]"2"[/COLOR] then calling     'Receive "vs2"
if b9=[COLOR="red"]"3"[/COLOR] then mailbox     'Receive "vs3"
 

Vroom

Member
Right, I see. Ok i will try do change that. Thanks. 5 sec bit long when I press switch on input Port and wait until serin timeout. Somebody said better separate serin 08M and four outputs to inputs 20X2 like 4bit great and simple fast, I will try like that.
 

Dippy

Moderator
Surely on the original code you only have to hold a button down for >200mS?
Is that really a great hardship?
 

hippy

Ex-Staff (retired)
On the 20X2 the button could be connected to one of the HINT pins. Although there will still be a delay until a button push is acted upon, the button pushed indicator ( the hintXflag ) will still show the button was pushed even if it was released before the timeout.
 

Dippy

Moderator
Pete, yes I realise that.
Therefore ,assuming no serial, while the serial-in-200mS-wait is happening there will be no reponse to a button press.
So, like I say...

Hippy, can the hint interrupt terminate a timeout pause and pop off to Interrupt handler?
 

hippy

Ex-Staff (retired)
I don't believe so, only prematurely terminate PAUSE plus TUNE and PLAY ( and maybe SOUND but not got the manual in front of me ).
 

Vroom

Member
Really! Okay. I changed 5 sec, I tried to press on input Port so nothing response while serin timeout, also changed HINT1/2 still nothing happen so weird. But gave up, I used other PICAXE 08M for serin only, simple 08M four outputs to inputs 20X2 like 4bit binary can up to 16 but use 15 so great fast can press inputs.

20X4

main:
if pinB.7 = 1 then check '4 bit binary
f pinB.6 = 1 then check '4 bit binary
f pinB.5 = 1 then check '4 bit binary
f pinB.4 = 1 then check '4 bit binary

if pinB.3 = 1 then reset
if pinB.2 = 1 then nextpage
goto main

check:
pause 100
if pinB.7=0 and pinsB.6=0 and pinsB.5=0 and pinsB.4=1 then run1
if pinB.7=0 and pinsB.6=0 and pinsB.5=1 and pinsB.4=0 then run2
.
.
.
.
if pinB.7=1 and pinsB.6=1 and pinsB.5=1 and pinsB.4=1 then run15
goto main

I like use 4bit binary inputs 20X2 from 08M receiver wireless only. I'm sorry my code maybe too long list, if anyone knew how could make simple short code. Thanks.
 
Last edited:

bpowell

Senior Member
So, here's how I read the situation:

You have a 20x2 that is receiving data from sensors (and it's receiving this data wireless via RF, right?) What the OP is saying (I think) is that, "Hey, I have this 200ms timeout, so I want to be able to push a switch locally to the 20x2 (hard-wired) and see something happen. Logically, if no data is received, the serial should time-out after 200ms, and the 20x2 should notice the switch being pressed locally and act accordingly. Why isn't this working?"

That's how I read the question...and the answer (again, I think) is that the serial-in will NEVER time-out if you're using a wireless RF solution such as a 433 mhz or 315 mhz RF transmitter / receiver pair...the reason is, the serial interface is constantly receiving data from the radio, it's just garbage...that's why you have to put the qualifier in there so the Picaxe knows when to start paying attention...however, as far as the timeout is concerned, the serial line is never quiet, so the timeout is never activated. Therefore, the Picaxe will stay in the serial-in loop forever until the correct data is received.

Your work-around of using an 8m to receive the RF data, and then pass it along to the 20x2 is a great idea, and solves the problem nicely.

Brendan
 

Dippy

Moderator
I think you may have cracked it brendan and the 2 micro approach sounds like it works nicely - it certainly has potential advantages.

Earlier on I couldn't see a real practical problem with a theoretical 200mS wait to respond to a button-press, but your thoughts sound really sensible.

Maybe he could go back to a single uP method if he (carefully) used edge-trigger interrupts or regular IF-ing in his code.
Anyway, i'm glad it's solved.
 

hippy

Ex-Staff (retired)
You have a 20x2 that is receiving data from sensors (and it's receiving this data wireless via RF, right?) ...and the answer (again, I think) is that the serial-in will NEVER time-out if you're using a wireless RF solution such as a 433 mhz or 315 mhz RF transmitter / receiver pair
You may be right, though I didn't see any indication of wireless being used until post #15, that would be the situation for dumb wireless modules, the timeout will likely not occur or be far longer than expected.

Even with timeouts when they work, Sod's Law says the data you want will arrive just after the timeout when you're not ready for it so you'll never see any data transmitted, and if you extend timeouts to ensure capturing that data you cause delays in the rest of your code.

In that respect timeouts, plus interrupts, often seem to be perceived as some sort of universal panacea to resolve problems and code conflicts when they are not. Both timeouts and interrupts should be used with care and not rushed into. Doing so may also overly complicate the code when there are better solutions available.

Using the AXE213 and NKM2401 RF interface one can poll for data having been received, read it is if it has, continue without any delay if not. That is usually far better than relying on timeouts to determine when nothing has been received.

The NKM2401 performs the off-loading of RF communications as previously recommended by using an additional PICAXE but more cheaply, potentially far more reliably, and without any effort to get the PICAXE off-loading code written and working.

A PICAXE front-end doing this off-loading may make more sense when data is not in eight byte chunks or one needs to filter on the data received but I'd probably choose to use a NKM2401 at both ends plus an additional PICAXE front-end to filter on the data packet received by the NKM2401 and to build up valid data packets to pass to the PICAXE. That's the best of both worlds, reliable comms, and being able pass to a PICAXE exactly what it needs. There is of course no need for any off-loading to another PICAXE when a single PICAXE can take the eight bytes from an NKM2401 and use that data as delivered.
 

Vroom

Member
bpowell- Yeah, you are right what I meant, thanks for your help the situation. That right I'm using a data wireless 433Mhz, really its hardly about the timeout is never activated! Its solved myself between 08M and 20X2 not a problem, but 08M should set the direction register outputs DIRS=%00111 when power up.

Hippy- sounds good idea another the way about AXE213 and NKM2401 I will curious about them when I get NKM2401 and test how work, haven't thought of that's the best of both worlds, thanks.
 
Top