Poor Man's PNS

slimplynth

Senior Member
It occurred to me the other day that I could use VBA macro's within Outlook or programmed into a picaxe to email me data from from my data logger at home, at regular intervals.

There a few approaches I'm considering.. one of them was to remove the encoder from a donated PS/2 Keyboard.

I don't require all of the functionality, the macro would ideally use very few key strokes to make it picaxe firendly - even something as simple as ALT Tab (change screen)>>> scrn print >>> alt tab + tab >>> ctrl V >>> ctrl + s >>>A.jpg >>>>Enter >>>Y (confirm overwrite) would let me get a screen shot of the debugger in the PE emailed to me.

I've studied and mapped the keyboard matrix to the pins on the encoder (no data sheet available unfortunately). If this one doesn't work I'll just keep looking for a keyboard with an available datasheet)

Has anyone else done anything similar... there a couple of threads in archive but they seem to be aimed more at using a keyboard with a picaxe to enter data.. where as i'm trying use a picaxe to emulate a keyboard entering data.... As im not goig to be using too many keys.. I was wondering how do i interface the pins on the encoder with the picaxe without using a multiplexer...

effectively, i'm attempting to replace the simple switches wth a pic output thats where i starting to get puzzled. Do i just have the connections going to the encoder and send the line high for what would be a normal ammount of time for a typical key press.. then take the picaxe pin low? or do i have to use a transistor... or a multiplexer :confused:, though If i'm going to buy one of those I might as well order one of the DIY arcade game encoders.

.. advice very welcome

Cheers

Lee
 

MartinM57

Moderator
Why not just use a PC-based tool to replay keyboard commands, mouse clicks etc...as is often done for automated testing.

Google "keyboard replay" and I'm sure you'll find (free) stuff....
 

slimplynth

Senior Member
Cheers Martin will take a look later, I'd planned to have the picaxe doing the repetitve keyboard stuff as part of a go sub in the Rx side of my data logger.. if i can get a program to achieve that.. even better. Still, these encoders look worth spending some time on just because of their abundance in the natural world :D and the endless possibilties
 

slimplynth

Senior Member
I've stripped the encoder out now, so i guess it's a bit like my gf's cat.. playing with a half dead mouse. Fun but infuriating (however cruel, the cat really does wish for an immortal mouse to play with :d)

I'll checkout the auto-hot-keys when i get back as i'm guessing thats what i've been looking for.

I would use a servo but I dont have one to hand, plus I was hoping to power the picaxe from the PS/2 line.

As for my other question re. the inputs on the encoder... it's been a good experience finding out how a keyboard operates but I'm still struggling to come to terms with how to use a picaxe to mimic the effect of a key being depressed.... which I'm sure is so simple I'll feel like an idiot when the penny drops.

On the original keyboard -

three sheets of acetate:

1) the top one forms a maxtrix using 8 tracks
2) the middle one has holes where the rubber spring/buttons sit
3) the bottom layer has a matrix for each key using 17 tracks.

To output a Letter "A", from mapping the matrix, I just need to short the pins on the encoder between 3 of 8 and 1 of 17 (not tried this yet as only finshed the map early this morning). If a single wire can do this, how do i go about it with a picaxe.. Is the transistor my best friend?
 

Jeremy Leach

Senior Member
Hi, I'm still trying to understand your setup!! So ..you've got a PC at home that's retrieving data from a picaxe datalogger and you want that PC to email screenshots to your work PC etc at regular intervals. Right??

And the keyboard encoder idea is to get the picaxe itself to generate keystokes to create an email with screen shot attachment and send to you??

If your Picaxe project is communicating serially with the PC then I'm sure it's possible to write VBA code in Outlook to get the serial data from the com port and dump it into an email. In the past I've dabbled with autoemailing data using VBA in Outlook, but not from the com port. Need to have pretty good grasp of VBA though.
 

slimplynth

Senior Member
Cheers for the replies.

Funnily enough Slurp that was my initial Idea after reading a few tutorials on the PS/2 protocol. Then I stumbled across a DIY arcade machine page that referenced keyboard hacks.

Jeremy, yes that's exactly the setup I have... 433Mhz tx... The Rx (will be) on my now redundant tower. My thought being that I only have to alt tab between two apps which will be running constantly, Outlook and the PE.

At say, 30 minute intervals I could have the Rx side picaxe (18X) goto a subroutine to send the email using the encoder.

Found this which looks promising though...

http://www.everythingaccess.com/tutorials.asp?ID=Outlook-Send-E-mail-Without-Security-Warning

includes the possibility of auto adding an attachment too, in this case it could be the text file I'm saving to; in an XML format, using the Eltima RS232 data logger program.

I'll carry on playing with the encoder for now.

edit: or not, i've left the pinout diagram on my desk at work.. doh!! but I've connected the encoder to the tower and connecting the pins with a single wire does give characters, might be best to sleep on this one - shorting the wrong ones could fry the motherboard.
 
Last edited:

hippy

Ex-Staff (retired)
Jeremy, yes that's exactly the setup I have... 433Mhz tx... The Rx (will be) on my now redundant tower. My thought being that I only have to alt tab between two apps which will be running constantly, Outlook and the PE.

At say, 30 minute intervals I could have the Rx side picaxe (18X) goto a subroutine to send the email using the encoder.
Nope; I'm completely confused :)

I've had a PICAXE connected to and old PC's so it could send SMS's, email and generate web pages for another PC ( or anyone in the world ) to view or receive, but I don't follow how you're imagining the setup you have and what will be doing what.

Using a PICAXE to work as a PS/2 keyboard seems overly complicated when you could just communicate via serial to what we'll call the server. Then it's just a matter of running the right application on the server to take the data it gets from the PICAXE and send it to another PC. I'm not clear on how Outlook and macros are going to help with that. I'm not sure what you mean by "encoder".

This could be a case of a picture ( or diagram ) being worth a thousand words.
 

slimplynth

Senior Member
the circus has come to town... I must be picaxe the clown

No worries hippy, I've got pictures but errr not with me either :D this is the kind of thing (read encoder) i do have in front of me though.. except the one ive taken out of a recycled PC keyboard.. doesn't have the nice headers or a datasheet, except for a chinese pdf that i couldn't even work out where to begin to download :D oh christ !! I'm comitting Forum Harry Karry with this now :D

I did get a data sheet for a completely different encoder (thingy ma bob :0)
that didn't help me much either :0)

So I sat down last night and started tracing all the lines from every key back to the relevant pad on the 'thingy ma bob' - to cut a dull story short I used my magnifying glass to assign the pads to the right pins on the thingy.

anyway I left that pinout diagram at work, because I have to leave manchester at exactly 4:59pm to give my 899cc fiat siecento a fighting chance in the rush hour traffic of the M60.

Believe me, I wish I had the combined skill and knowedge of the forum to write in VB.net... and know everything about everthing IC.. the sad truth is I don't... but I am a keen bodger.

So my plan, was simply (someone please shooot me :D) thus:

I know that to take a screen shot of the debugger in the PE and paste into and send an email will require very few key strokes.. the problem is I only have an idea of how to actually interface a picaxe with the thingy (encoder)(regardless of whether I could write an app to do exactly the same thing, i dont/can't do that (well not yet)...

Maybe I should have intially just asked.. "Help!! who can tell me what i need to do to make a picaxe act as if it's a button, or several buttons?"

"I'll get my coat" ;0)
 

Attachments

slimplynth

Senior Member
Autohotkeys

Check out Autohotkey @ http://www.autohotkey.com/ (It's free)

I have used it for various things with great success. Powerful yet easy to use.

Using it, you could for example have a Picaxe depress a key on the keyboard physically (with a servo) and Autohotkey will do the rest. Or you could solder wires directly to one or two keys on the keyboard. Or you could hack an old mouse (See: http://www.picaxeforum.co.uk/showpost.php?p=77147&postcount=9)

Have fun.
Cheers Boriz:cool:, AutoHotKeys is the Dogs Danglies, It's exactly what I was looking for.

I found this gem of a post on the hotkey forum.

It allows automatic sending of an email (gmail) + attachment(s), using exactly what's required - a single key stroke and no email prog. (it was very easy to setup too).

still planning on using the keyboard 'thingy' :) probably with a mechanical switching mechanism for now though, driven by a picaxe which will activate the auto email at regular intervals and upon significant changes).

Will definitely dedicate some time to VB when this is completed, aiming to cut out the middle man.

Thanks
 

boriz

Senior Member
You're very welcome. It's always nice to get feedback. AutoHotkey is very useful for lots of things. Glad to hear it's working for you. I recommend everyone here takes a look at it.
 

slimplynth

Senior Member
Nope; I'm completely confused :)

I've had a PICAXE connected to and old PC's so it could send SMS's, email and generate web pages for another PC ( or anyone in the world ) to view or receive, but I don't follow how you're imagining the setup you have and what will be doing what.

Using a PICAXE to work as a PS/2 keyboard seems overly complicated when you could just communicate via serial to what we'll call the server. Then it's just a matter of running the right application on the server to take the data it gets from the PICAXE and send it to another PC. I'm not clear on how Outlook and macros are going to help with that. I'm not sure what you mean by "encoder".

This could be a case of a picture ( or diagram ) being worth a thousand words.
Maybe I should have called this thread "Sub Standard / Poor Quality PNS" and i do pray an actual PNS will be in my birthday present stack later this month :D but here's the details an pix I promised.

The encoder - (I know now, after reading one of Dr_Ac's posts that I'll be better off with VB - using the sendkeys function (i think) - In any case It was a good mental work out and quicker doing it this way with the keyboard hack - as opposed to learning to do it in VB (which is my next project).

Also a pinout for the encoder (whatever it's propper name is - i'm completely unsure and hoping hippy or anyone else can confirm :confused:)

Also attached, a table showing how the matrix maps, shorting an (n)i with an (n)ii pin produces a character referenced in the table. A few pins were impossible to assign, but as the datasheet doesn't appear to be available and I can live without them - not really bothered for now.

Code:
#Include TXT.ahk
1::

sendinput {Tab}{Tab}{Tab}

sendinput {Enter}

FileAppend,</xml_dl>,C:\Users\Elmo\Desktop\data\data.txt

lline := TXT_Tail("c:\Users\Elmo\Desktop\data\data.txt",7)

FileCopy, C:\Users\Elmo\Desktop\data\data.txt, C:\Users\Elmo\Desktop\data\data.xml,1								

sFrom     := "your_email@googlemail.com"
sTo       := "Any_email@hotmail.com"
sSubject  := "Update - Data Logger"
sText     := lline
sAttach   := "C:\data\data.html"
dAttach	  := "C:\data.xml"

sServer   := "smtp.gmail.com" ; specify your SMTP server
nPort     := 465 ; 25
bTLS      := True ; False
sUsername := "Your_Gmail_Username"
sPassword := "Your_Gmail_Password"

COM_Init()
pmsg :=   COM_CreateObject("CDO.Message")
pcfg :=   COM_Invoke(pmsg, "Configuration")
pfld :=   COM_Invoke(pcfg, "Fields")

COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/sendusing", 2)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", 60)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpserver", sServer)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpserverport", nPort)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpusessl", bTLS)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/sendusername", sUsername)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/sendpassword", sPassword)
COM_Invoke(pfld, "Update")

COM_Invoke(pmsg, "From", sFrom)
COM_Invoke(pmsg, "To", sTo)
COM_Invoke(pmsg, "Subject", sSubject)
COM_Invoke(pmsg, "TextBody", sText)
COM_Invoke(pmsg, "AddAttachment", sAttach)
COM_Invoke(pmsg, "AddAttachment", dAttach)
COM_Invoke(pmsg, "Send")

COM_Release(pfld)
COM_Release(pcfg)
COM_Release(pmsg)
COM_Term()

FileDelete, C:\data\data.txt

FileAppend,<xml_dl>,C:\data\data.txt

sendinput {Tab}{Tab}{Tab}


sendinput C:\data\data.txt

sendinput {Tab}{Tab}{Tab}{Tab}{Tab}{Tab}{Tab}{Enter}
Above is the AHK script (AutoHotKeys - suggested by Boriz) its written and based on, an auto email script originally posted by some cool guy named Sean It also requires the AHK TXT script.

The script runs whenever the "1" key is entered on the keyboard; The 18X I have on the Rx side of my 433MHz data logger outputs (Sertxd) data in an XML format but saved as a txt file.

e.g.

Code:
<xml_dl>
<num>1
<time>0:07:20</time>
<day>1</day>
<temp>33</temp>
</num>

<num>2
<time>0:07:30</time>
<day>1</day>
<temp>33</temp>
</num>

<num>3
<time>0:07:40</time>
<day>1</day>
<temp>33</temp>
</num>
The script's function is to stop the RS232 Data Logger Program (freeware) (by Elmtima) from archiving. The script then appends the txt file to include the final </xml_dl> tag and saves as "data.xml" and subsequently deleting the original data.txt file.

Following on, AHK script emails the xml file to the address(es) specified, (Using gmail - has to be Gmail for this script), along with an HTML file (to allow the results to be viewed in a table format). The text body of the email also contains the last 7 lines of data, from the attachment.

the HTML code:

Code:
<html>
<head>

</head>


<body>

<script type="text/javascript">
var xmlDoc=null;
if (window.ActiveXObject)
{// code for IE
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
else if (document.implementation.createDocument)
{// code for Mozilla, Firefox, Opera, etc.
xmlDoc=document.implementation.createDocument("","",null);
}
else
{
alert('Your browser cannot handle this script');
}
if (xmlDoc!=null) 
{
xmlDoc.async=false;
xmlDoc.load("data.xml");
var x=xmlDoc.getElementsByTagName("num");

document.write("<table border='1'>");
document.write("<thead>");
document.write("<tr><th>Reading(10 seconds)</th><th>temp</th><th>light</th></tr>");
document.write("</thead>");

for (var i=0;i<x.length;i++)
     
{ 
var w=i+1
document.write("<tr>");
document.write("<td>");
document.write([w]);
document.write("</td>");

document.write("<td>");
document.write(x[i].getElementsByTagName("temp")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("</tr>");

}

document.write("</table>");
}
</script>

</body>
</html>
Email now sent, the AHK script restarts the Eltima Data Logging program, using the same filename as it was originally, "data.txt".

And so the cycle continues - will be set to email once every hour or upon significant change.

The reason for the keyboard encoder was to allow the AXE090 with an 18X running the show to respond to any data/variable changes (because I'm unable to do it in VB)...

There's only temp on there at the minute but future improvements will be the addition of a PIR sensor in the kitchen, to use in conjunction with a webcam and have the script email a picture when anything changes/moves (scripts available on searching AutoHotKey).

Also a smoke detector... "Email >>>> from: "me" to: "me too" subject: "House on fire!!!" --- Doh!!! no good if im in manchester i guess but surprises like that are never good, who knows but its better to know, bad news travels at the speed of email in this case :)

Will also use the AHK script to autocomplete one of the free SMS websites and send a txt message.

Below is the Picaxe code, previously posted, for the 433tx/rx data logger - sorry no pics in project boxes - so i aint posting :D

Rx code: the crude time counter doesn't matter for now, will get accurate when my birthday order with Rev-ed is delivered.

Code:
init:
pause 10000 	'used this to give me time to switch apps and start the Eltima - data logging program
		' freeware RS232 data logger - http://www.eltima.com/products/rs232-data-logger/


sertxd(60,"xml_dl>",13,10)

symbol flash = 50

symbol ok_led = 0

main:

for w0=1 to 365
	for b2=0 to 23
		for b3 = 0 to 59
			for b4 = 0 to 5
			high ok_led
			b5=b4*10
			w4=w4+1
			
			pause 9120 'wait ten seconds
	        	serin 2,N2400,("data"),b6,b7
	        	low ok_led 'special effects
	        	let b6=b6-3
	        	sertxd(60,"num",62,#w4,13,10)
			sertxd(60,"time",62,#b2,":",#b3,":",#b5,60,47,"time",62,13,10)
			sertxd(60,"day",62,#w0,60,47,"day",62,13,10)
			sertxd(60,"temp",62,#b6,60,47,"temp",62,13,10)
			sertxd(60,47,"num",62)
			sertxd(13,10,13,10)
			
			next b4
		next b3
	next b2
next w0



goto main
Tx code:


Code:
Main:

readtemp 5,b0
serout 1,N2400,(0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55) ' preamble to lock link the tx/rx
pause 5 // lock link and preamble solution by wolfgang ;0) cheers
serout 1,N2400,("data",b0)
pause 1000
goto main
I think that's it.. I just need to find a way to connect/interface the encoder with the picaxe so that it sends the required "1" character - if anyone has any ideas on how to do this please let me know an I'll put you on my xmas card list - cheers
 

Attachments

Last edited:
Top