Adding Remote control

oracacle

Senior Member
As I have been updating the camera controller for the new sensors, I have been thinking about remote controlling the controller.
As it currently stand there is a 20x4 OLED and six buttons using a multiplex setup, this would be replicated on the remote
If we assume that during initial start up that another PICAXE can be detected of some form of radio link (thinking about 10 ish meters - the more the better, but cross that bridge later). What would be the best way to get the display to update and send the key press data back.
I am thinking during the detection of the remote a flag would be set so that the keys on the main controller a no longer work, and a generic message displayed on the OLED. Sending what they press back to the main controller should, in theory at least, be fairly strait forward. send a number that corresponds to the selection (pretty much what the key press routine does anyway) back the waiting controller.
What is being displayed is slightly trickier. A custom built backpack for the remote display could mean that entire screen prints could be sent byte by byte, on the other hand it maybe better to have pre-programmed displays and simply call each display.

The first option would mean that I could use the code already in the main controller, but would also affect the main display when there are things that don't need to be displayed are transmitted
The second option would increase the code load in the main controller to a greater degree, it would also mean that future updates would need to be programmed into the remote control too

there is a third option as well I suspect. This it to recode the backpack of the in the main controller display. In this instance I would remove control of the 3 extra pins and use that code section to ignore all coms until a certain data set is received which will make it drop back into main mode. This route would mean that the display code can stay unchanged with a simple flag check when user input is called for. the transmitter would be connected the same serial line as the OLED display, I have at least 5 spare pins but there are a lot of menus to display and repeating the code for a different pin seems excessively bulky.

anyone had experience with this sort of thing?
any idea on how you would go about it?
 

PhilHornby

Senior Member
Sounds do-able!

Personally, I would consider using HC-12 Radio Modules for this - discussion here: http://www.picaxeforum.co.uk/showthread.php?28893-HC-11-and-HC-12-transceiver-modules

What would be the best way to get the display to update and send the key press data back.
Simple serial data, written using SEROUT to the HC-12. I'd probably incorporate a Sequence No. and maybe a CRC/Checksum if false triggering has to be avoided. I'd also have response message to indicate success/failure of the command sent.

If the Picaxe at the Controller is not an X2 (ie no background serial receive), you can work around it. Set an interrupt for the pin doing the serial receive, and the transition of the first bit, of the first byte received will trigger the interrupt. (So the transmitter sends a wake-up byte, pauses, and then the rest of the data - probably with a easily detected prefix. The interrupt service routine in the receiver just issues a SERIN with a timeout, specifying the same prefix, to grab the data. Then it replies to the sender, which is waiting on a similar SERIN)

What is being displayed is slightly trickier. A custom built backpack for the remote display could mean that entire screen prints could be sent byte by byte, on the other hand it may be better to have pre-programmed displays and simply call each display.
I would just send a code, indicating the message text to be displayed. The Sender and Receiver could share a .BASINC file, to ensure they're kept in line. Trying to send the raw data for the display might make for a 'jerky' update of your OLED, due to the 'packetising' of the data by the radio modules.
 
Last edited:

oracacle

Senior Member
I did think about the include file, however I did neglect to mention that the controller is using 4 programme keep to keep the programme structure manageable and easily updatable.
The sending of a flag to call certain displays will work for the most part - but not for all. there are sections where only a few characters are updated, but sending a prefix to drop into "pass through" mode on the remote and could work.
Maybe a case of getting a couple HC-12s and trying some stuff, even if its just to dismiss the idea from ones mind

a quick example of updating the timing values for the flash strobe control
Code:
	strobval = strobval - 10				'decrease time between strobes
		if strobval > 16000 then			'check for underflow
			let strobval = 16000			'correct for underflow
		end if
	let tempword0 = strobval /8				'correct for display
	let tempword1 = strobval //8				'correct for display
	'inser blank to remove number that may not get over writien
	if tempword0 <10 then
		serout screen, baud, (254, 134, 32, 32, 32, #tempword0,46,#tempword1)
	else if tempword0 >9 and tempword0 < 100 then
		serout screen, baud, (254, 134, 32, 32, #tempword0,46,#tempword1)
	else if tempword0 >100 and tempword0 <1000 then
		serout screen, baud, (254, 134, 32, #tempword0,46,#tempword1)
	else
		serout screen, baud, (254, 134, #tempword0,46,#tempword1)
	end if
 

inglewoodpete

Senior Member
You may want to use the following display code to save over 30 bytes of space. I have also replaced ASCII codes with actual characters to make it a little more readable. Note that tempword0 can never be greater than 2,000, so more bytes could be saved.
Code:
   [color=Purple]strobval [/color][color=DarkCyan]= [/color][color=Purple]strobval [/color][color=DarkCyan]- [/color][color=Navy]10            [/color][color=Green]'decrease time between strobes
      [/color][color=Blue]if [/color][color=Purple]strobval [/color][color=DarkCyan]> [/color][color=Navy]16000 [/color][color=Blue]then         [/color][color=Green]'check for underflow
         [/color][color=Blue]let [/color][color=Purple]strobval [/color][color=DarkCyan]= [/color][color=Navy]16000          [/color][color=Green]'correct for underflow
      [/color][color=Blue]end if
   let [/color][color=Purple]tempword0 [/color][color=DarkCyan]= [/color][color=Purple]strobval [/color][color=DarkCyan]/[/color][color=Navy]8         [/color][color=Green]'correct for display
   [/color][color=Blue]let [/color][color=Purple]tempword1 [/color][color=DarkCyan]= [/color][color=Purple]strobval [/color][color=DarkCyan]//[/color][color=Navy]8        [/color][color=Green]'correct for display

   [/color][color=Blue]serout screen[/color][color=Black], [/color][color=Blue]baud[/color][color=Black], [/color][color=Blue]([/color][color=Navy]254[/color][color=Black], [/color][color=Navy]134[/color][color=Blue])
   [/color][color=Green]'Add leading zero blanking to ensure old number is overwritten.
   [/color][color=Blue]if [/color][color=Purple]tempword0 [/color][color=DarkCyan]< [/color][color=Navy]100 [/color][color=Blue]then serout screen[/color][color=Black], [/color][color=Blue]baud[/color][color=Black], [/color][color=Blue]([/color][color=Red]" "[/color][color=Blue])[/color][color=Black]: [/color][color=Blue]EndIf
   if [/color][color=Purple]tempword0 [/color][color=DarkCyan]< [/color][color=Navy]1000 [/color][color=Blue]then serout screen[/color][color=Black], [/color][color=Blue]baud[/color][color=Black], [/color][color=Blue]([/color][color=Red]" "[/color][color=Blue])[/color][color=Black]: [/color][color=Blue]EndIf
   if [/color][color=Purple]tempword0 [/color][color=DarkCyan]< [/color][color=Navy]10000 [/color][color=Blue]then serout screen[/color][color=Black], [/color][color=Blue]baud[/color][color=Black], [/color][color=Blue]([/color][color=Red]" "[/color][color=Blue])[/color][color=Black]: [/color][color=Blue]EndIf [/color][color=Green]'Is this statement required?
   [/color][color=Blue]serout screen[/color][color=Black], [/color][color=Blue]baud[/color][color=Black], [/color][color=Blue]([/color][color=Black]#[/color][color=Purple]tempword0[/color][color=Black], [/color][color=Red]"."[/color][color=Black], #[/color][color=Purple]tempword1[/color][color=Blue])[/color]
 
Last edited:

oracacle

Senior Member
Thanks, that will go into the next update.
actual programme space isn't a real issue at this time but something to bare in mind.
 
Top