Beginner help with a project

Iver

New Member
Hi, I'm trying to control a device I've built from a commercial software App. My idea seems very simple but I have had no success so far. I need to activate a relay for about 1.5 sec. when the software sends a serial command. I am using an 08m with the code below. This works about 75% of the time but I get no reaction 25% of the time (It's like the input is not heard). I have also tried to isolate a signal from the serial port with a diode but I don't seem to get enough voltage to activate a transistor switch to use as a pulse signal. My electronic skills are very basic so please keep that in mind if you have any suggestions.
Any ideas would be very welcome,
-Iver
Code:
main:
serin 1, n2400, w1
if w1 > 5  then 
goto filter
else
ENDIF
GOTO MAIN
filter:
high 4
pause 15000
low 4
goto main
 
Last edited:

steliosm

Senior Member
Hello Iver.
Can you provide more information about the data that you send to the PicAxe throught the serial connection? I noticed that you are using a word variable.

Maybe this code will work for you:

main:
serin 1, n2400, w1
if w1 > 5 then goto filter
goto main

filter:
high 4
pause 15000
low 4
goto main
 

moxhamj

New Member
Have a look at page 139 of the second manual - Basic commands. Serin works better with a qualifier eg serin 1,n2400,("ABC"),w1

And change your sending code to put "ABC" in front of the numbers. Then it will only look for w1 after it has got ABC. At the moment it might be reading half of w1 on one read and the second half on another read and you will get garbage some of the time.
 

Iver

New Member
Thanks for the reply Stelios, my knowledge of serial protocol is almost none. I hooked a meter up to the serial pins 3 and 5, it seems to be a short burst of pulses. I tried variations of the code with b1 and pulsin with the same unreliable result. I'll try your code tonight.
Thanks,
-Iver
 

Iver

New Member
Thanks Dr Acula, I had read that already, I'm just not sure how to determin what ABC should be?
-Iver
 

moxhamj

New Member
I doesn't matter. ABC are just a series of binary numbers that have to arrive in a certain order to trigger serin. Eg ABC is actually ascii 65,66,67. I use ABC for most things, but sometimes I go a bit wild and use XYZ or complete words like "DataPacket". It doesn't really matter.
 

Iver

New Member
Well, what I mean is I am using a comercial device driver to control my homemade device. How would I determin what the software is sending out?
-Iver
 

moxhamj

New Member
Ah. Do you have any control over the software of that device? Do you know the make and model number? It may be sending data in a proprietory packet - eg a group of exactly 64 bytes with a checksum at the end, or something like that. You might be able to find out a bit by doing a serin 1, N2400,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13 and then do a debug and see what those registers contain. Maybe you will see a pattern.
 

hippy

Ex-Staff (retired)
If you tell us what the commercial application / driver is someone may recognise it or be able to work out what it is sending.
 

Iver

New Member
Hi Hippy, my device is a filter wheel for an astronomy camera. The software I use has drivers for a number of comercial filter wheels however the one I am trying to emulate is a Homeyer MFW, it's the only driver that didn't require a hand shake! I've been using my filter wheel for a few years with a hand control to advance it, but it would be nice to automate it. I've searched on line and it looks like each of the six positions has a # 1200 1800 2400 3000 3600 4200. When I tried to debug the value I either get 255 or no response.
I'll try some of the suggestions I recived and see if I can make any progress.
Thanks,
-Iver
 

moxhamj

New Member
I couldn't find a manual with a quick search - do you have any more information about the serial link eg baud rate, parity, protocols? Reverse engineering someone elses protocols might end up being tricky.
 

hippy

Ex-Staff (retired)
I couldn't find any details on the Homeyer protocol. One option is to feed the output from the PC serial port via a cross-over / null-modem cable into another port or to a port on another PC and run a Terminal Emulator there. This is how I normally try to determine unknown PC protocols.

http://www.picaxeforum.co.uk/showthread.php?t=8961

Select Display->Show Frames and this will allow quick and easy selection of baud rates. Try them all until what is sent by the control software shows something consistent and hopefully meaningful and readable.

That's easier and quicker than trying to download a program into a PICAXE to do the job IMO.
 

Iver

New Member
Well, I was able to find some more info. about the protocol. The driver sends six different signals, one for each filter position. Each signal is a burst of 60 pulses at a different pulse width. I don't think there is any way to measure this with a PICAXE is there??? So I won't be able to program the PIC to go to a specific position only to the next position. That's better then nothing. Thanks for the help.
-Iver
 

hippy

Ex-Staff (retired)
Are you sure that's the protocol for the serial version of the Homeyer MFW ???

Did you try observing what gets sent out the serial port using a Terminal Emulator ?

If it really is a pulse-width scheme there are only two ways to send that using a PC's serial port, by sending character codes which have a certain number of consecutive bits set and cleared ( how I'd do it ) or by pulsing the CTS or DTR handshaking lines from the PC.

Either way that should be easy enough to decode by a PICAXE using PulsIn.
 

Iver

New Member
Thanks for the reply Hippy, I'm not totally sure that's the correct protocol, however in my searches I read a number of times that the Homeyer wheel uses the SBIG protocol so I found this on SBIG's site
http://www.sbig.com/pdffiles/supporting.cfw-6-8.pdf
My interpretation of what I read may be incorrect however.


I hadn't tried to view the terminal data because I thought I had found out what it was. If my interpretation is correct however won't pulsin just count pulses?

Thanks again for your help,
-Iver
 

Iver

New Member
Hi again, I just tried the terminal emulator the results are as follows for each of the six positions.

1= FC
2= F8
3= F0 each value was repeated 51 times
4= C0
5= 80
6= 00

Do you think the PICAXE can read these? If so which input format should I try?

Thanks,
-Iver
 

westaust55

Moderator
I need to activate a relay for about 1.5 sec.
instead of the delay given in your code, that is:

Code:
 pause 15000  ; this is for 15 seconds.
you will need:

Code:
 pause 1500     ; for 1.5 seconds
 

hippy

Ex-Staff (retired)
@ Iver : Looks like consecutive number of bits set/ clear is the key, so this code will read the byte and determine the wheel position 1 .. 6 in b1

Code:
Do
  SerIn RX_PIN, RX_BAUD, b0
  b1 = $FF
  LookDown b0,( $FC, $F8, $F0, $C0, $80, $00), b1
Loop While b1 > 5
b1 = b1 + 1 ' Leave this out for a result 0..5 rather than 1..6
 

Iver

New Member
Serial input help! Hippy or anyone (original thread)

This was my original question in case this is any help.
 
Top