serin time out on 08m2

Wingrider

New Member
need help can't find answer in manual. Is there a way to detect the absence of serial data on the serin c.5 on the 08m2 without using the timeout ?
As I under stand it I can't use timeout option on the 08m2 with the hserin command.
I need to send serial data at 19200,n,1 and if I use the serin I believe it sets the ports to 4800,n,1.


Code:
Main: 
   serrxd [500,No_Serial_Data],($10)		' wait for hex 10
   If Activated = 0 then
     pause 12000
     High sense_out 					' Open sense relay
     pause 4000
     gosub Start  
     Activated = 1
   endif
   If Switch = 0 and Counter = 0 then
      gosub Lockout_Override
   else    
     if Switch = 1 then
        Counter = 0
     endif
   endif 
   Low sense_out
   Low Serial_line
   goto Main
 
   No_Serial_Data:							     	' No serial data receive
   Activated = 0
   goto Main   
end
 

westaust55

Moderator
Can you clarify exactly what you are trying to do as some of your statements and code example are conflicting / using different commands to that your text discusses.

yes state:
I can't use timeout option on the 08m2 with the hserin command.
which is correct - the M2 parts only have 2 byte buffer as per PICAXE manual 2. Data must be read on the fly and there is no timeout parameter/capability.

then state:
I need to send serial data at 19200,n,1 and if I use the serin I believe it sets the ports to 4800,n,1.
Where have you deduced this from? Can you provide a reference?
While I am no expert on the hardware serial IO (via the PIC MSSP module which supports the hardware SPI and i2c comms)
hserin/hserout are via hardware modules (using the HSERSETUP command first) whereas the serin and serout commands are firmware (programmed) commands.

hserin is only possible using the 08M2 pinC.1

but then in your code snippet you have:
serrxd [500,No_Serial_Data],($10) ' wait for hex 10
SERRXD is serial input via the programming input and the baud rate is a function of the PICAXE clock speed - ie 400 bps with a 4 MHz clock and 9600 bps with an 8 MHz clock.
SERRXD is the correct command for serial input via the 08M2 pin C.5


I need to send serial data at 19200,n,1
Confirm that this is sending serial data to the PICAXE 08M2 (ie serial input to ==> receiving at the PICAXE) and not sending from the PICAXE.


With the PICAXE M2 parts, the SERIN command can be used for baud rates up to 19200 bps but as can be seen from PICAXE manual2 page 204, this requires the PICAXE clock to be set to 16 MHz. See the SETFREQ command.

Likewise with the SERRXD command, for 19200 baud, the PICAXE clock will need to operate at 16 MHz.
 
Last edited:

Wingrider

New Member
Sorry for the confusion. I am using serrxd for the time out function.
My understanding from reading the manual was that serrxd would only operate at 4800 regardless of clock speed.

What I have is a piece of equipment that I need to send serial data to from the 08m2.
if the equipment stops sending serial data ,which I monitor on C.5 reason for the time out , I have the 08m2 resend the start up data to the equipment.

If I send the data based on a 20 sec. delay when this program start the data words and the equipment starts up.
When I use the serrxd command the equipment doesn't start properly.



Thank you for clearing that up and for your help

I have simplified the code to execute only this function. I will run it later today. Here is the simplified code.

Code:
#PICAXE 08M2

' ********************    Inputs   **********************************

symbol	 Speedsense_in  = C.3     'speed sense signal in IC pin 4
' Serial data in = C.5 

' ********************    Outputs  **********************************    

symbol	 sense_out       = C.4 	' speed sense relay pin3
symbol       Serial_Line     = C.2  ' Serial Line relay pin 5 
symbol 	 Serial_Sting    = C.0	' Hserout pin 7


' ******************** 	   Variables *********************************     
	
symbol       Activated = b0			' Serial in varialbe  
symbol       No_Serial_Flag = b7		' Serial in varialbe  

'  ********************    Init  ************************************    :
let Activated = 1
Low Serial_line				' Close serial line relay
Low sense_out	 			' Close sense_out Relay  
						 

setfreq M16	
hsersetup 207,%00000			'from picaxe calculator
pause 500 
disconnect
pause 500

Main: 
   serrxd [500,No_Serial_Data],($10)		' wait for hex 10
   If Activated = 0 then				' if 0 equipment not runnunig 
     pause 12000						' so send start commands
     High sense_out 					' Open sense relay
     pause 4000
     gosub Start  
     Activated = 1
   endif
   goto Main
 
  No_Serial_Data:							     	' No serial data receive
   Activated = 0
   goto Main   
endif

Start:	
   gosub Enter								' Enter command routine
   gosub Display								' Display command routine
   Low Serial_line							' Close serial line relay
   Low sense_out	 				      		' Close sense Relay  		
   							
return


Enter:
		high Serial_line						' Open serial line relay
		pause 500							' pause .25 sec.	
	
	
		' Send Enter command sting
		
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0C,$FF,$FF,$FF,$CC,$10,$10,$36,$12,$1B,$F1,$F5,$F5,$80,$E8)		
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0C,$02,$FF,$FF,$CC,$30,$75,$12,$1B,$F1,$F5,$F5,$80,$88)
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0C,$03,$FF,$FF,$CC,$82,$72,$12,$1B,$F1,$F5,$F5,$80,$38)										' Pause for .25 seconds
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0D,$0A,$04,$FF,$FF,$CC,$19,$1B,$F9,$12,$1B,$F1,$F5,$F5,$80,$18)
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0D,$0A,$1B,$FF,$FF,$CC,$15,$22,$26,$12,$1B,$F1,$F5,$F5,$80,$D1)
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0C,$FF,$FF,$FF,$CC,$10,$10,$36,$12,$1B,$F1,$F5,$F5,$80,$E8)
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0C,$02,$FF,$FF,$CC,$30,$75,$12,$1B,$F1,$F5,$F5,$80,$88)
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0C,$03,$FF,$FF,$CC,$82,$72,$12,$1B,$F1,$F5,$F5,$80,$38)
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0D,$0A,$04,$FF,$FF,$CC,$19,$1B,$F9,$12,$1B,$F1,$F5,$F5,$80,$18)		
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0D,$0A,$1B,$1B,$FF,$CC,$15,$22,$26,$12,$1B,$F1,$F5,$F5,$80,$D2)		
	
		
		pause 500							' pause .25 sec.
      	low Serial_line						' Close serial line relay
return	

Display:

		high Serial_line						' Open serial line relay
		pause 1000
		
		 
		' Send Display command sting  
		 
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0C,$FF,$1B,$03,$CC,$14,$26,$12,$1B,$F1,$F5,$F5,$80,$F3)	
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0C,$02,$1B,$03,$CC,$34,$64,$12,$1B,$F1,$F5,$F5,$80,$94)		
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0C,$03,$1B,$03,$CC,$83,$04,$12,$1B,$F1,$F5,$F5,$80,$A4)		
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0D,$04,$1B,$03,$CC,$1B,$1B,$F9,$12,$1B,$F1,$F5,$F5,$80,$30)	
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0D,$1B,$1B,$03,$CC,$15,$22,$65,$12,$1B,$F1,$F5,$F5,$80,$91)
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0C,$FF,$1B,$03,$CC,$14,$26,$12,$1B,$F1,$F5,$F5,$80,$F3)
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0C,$02,$1B,$03,$CC,$34,$64,$12,$1B,$F1,$F5,$F5,$80,$94)
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0C,$03,$1B,$03,$CC,$83,$04,$12,$1B,$F1,$F5,$F5,$80,$A4)
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0D,$04,$1B,$FF,$CC,$1B,$1B,$F9,$12,$1B,$F1,$F5,$F5,$80,$32)
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0D,$1B,$1B,$FF,$CC,$15,$22,$65,$12,$1B,$F1,$F5,$F5,$80,$93)
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0C,$FF,$1B,$FF,$CC,$14,$26,$12,$1B,$F1,$F5,$F5,$80,$F5)
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0C,$02,$1B,$FF,$CC,$34,$64,$12,$1B,$F1,$F5,$F5,$80,$96)
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0c,$03,$1B,$FF,$CC,$83,$04,$12,$1B,$F1,$F5,$F5,$80,$A6)
		hserout  Serial_Sting, ($10,$03,$10,$8A,$0D,$04,$1B,$FF,$CC,$1B,$1B,$F9,$12,$1B,$F1,$F5,$F5,$80,$32)
			
		pause 500							' pause .25 sec.
      	low Serial_line						' Close serial line relay
return
 
Last edited:

Wingrider

New Member
Again thanks for the input. Turns out C.3 was electrically bad and was staying low, pulling the input signal low. After using a new chip everything is running fine.
 
Top