Looking for insights

dabineri

Member
Found the 20x2 - one of the picaxe family.

Why are you running at 32mhz, so as not to miss short pulses?

Where is the listing that correlates the picaxe model and the number on the chip?

Where do I find a complete list of directives like #No_Data,#No_Table so that I can understand them?

Thanks for all your assistance.
Dave
 

Michael 2727

Senior Member
Hi Dave,
A little reading may help you out with answering some of your most basic questions.
There are 3 files you may like to have a go at first, they are -
Picaxemanual1.pdf
Picaxemanual2.pdf
and Picaxemanual3.pdf
The links to these 3 files is directly above, top of the page ^^^.

#1 explains about the Picaxe system, Family of chips, other stuff.
#2 has every Command available to use, including Directives and Setfreq.
#3 has info on interfacing, circuits and hardware etc.
 

westaust55

Moderator
Hippy, what is the terminology 20X2?

Thanks,
okay while you found out that the 20X2 is a member of the PICAXE family, this is why it is good to read through the PICAXE manuals.

PICAXE manual 1 pages (around) 9 to 11 have the pinout for all PICAXE chips and there is a full list identifying which Microchip PIC each PICAXE chip is based upon at around page 16.
 

hippy

Technical Support
Staff member
Why are you running at 32mhz, so as not to miss short pulses?
In truth it's more a pragmatic decision because I couldn't get the code to work reliably at 8MHz but upping to 32MHz did. For me it wasn't worth worrying over why it wasn't reliable at slower speed when faster speeds were available and did work.
 

dabineri

Member
Thanks, Michael. I was looking at Manual2 Page 7 where they give many examples of directives but don't actually list all the possibilities.
Found it elsewhere.
Not sure why they would do it all at once, list all the possibilities and then give examples.

Dave
 

dabineri

Member
Still Looking

I am still working on this and now it is looking like the channel data coming in on the com port is more reliable than the IR codes.

So, now the question is how to read data coming in from a com port (9600,N,8,1). Do I need to set up a UART or are there easier ways to capture the signal?

Thanks, Dave
 

inglewoodpete

Senior Member
The 20X2, 28X1, 28X2, 40X1 and 40X2 all have an inbuilt, dedicated UART that can receive serial in the background (Ie while the PICAXE code is off doing something else). The M2-series PICAXEs can handle firmware-based (foreground) serial at 9600 baud. From memory, I don't think the older M-series can.
 

dabineri

Member
Thanks for this! Now I am confused about the WRITE command.

In manual 2, pg 191 it says: write location, data .. which I believe means save data at location. And yet in their example at the bottom o the page they say

write b0, b1 'write value into b1
This would imply write data, location would it not?

Can you clarify this for me, which way around is it?

Thanks for your help, Dave
 

hippy

Technical Support
Staff member
write b0, b1 'write value into b1

That's either typo or badly worded which I've noted, probably a copy-and-paste and not fully edited error. The actual behaviour is ...

Write b0, b1 ' Writes value in b1 to Eeprom location indicated by b0

Read b0, b1 ' Reads value at Eeprom location indicated by b0 into variable b1
 

westaust55

Moderator
Thanks for this! Now I am confused about the WRITE command.

In manual 2, pg 191 it says: write location, data .. which I believe means save data at location. And yet in their example at the bottom o the page they say

write b0, b1 'write value into b1
This would imply write data, location would it not?

Can you clarify this for me, which way around is it?

Thanks for your help, Dave
@dabineri,

Firstly, please update to the latest version of the manual. You must be using V6.7 or earlier based on the reference to page 191 for the write command.
The manual 2 is now at V7.2 (having gone through 5 iterations since).

The Programming Editor (currently at at V5.3.4) contains the latest manuals or you can download via the PICAXE Manual link in the orange bars at the top of the forum pages.

The PICAXE manual 2 (V7.2) states:
WRITE location,data ,data, WORD wordvariable...
- Location is a variable/constant specifying a byte-wise address (0-255).
- Data is a variable/constant which provides the data byte to be written. To use a word variable the keyword WORD must be used before the word variable.
Function:
Write byte data content into data memory.

Note that "EEPROM" and "data" are used interchangeably by Rev Ed (see Manual 2 page 61) so this is the non volatile memory area (at least until a new program is downloaded).


so, as hippy has already summarised

write b0, b1

b0 is the EEPROM memory location.

b1 is the actual data value to be saved into the indicated EEPROM memory location (pointed to by b0)
 

dabineri

Member
Looking For Insights

OK, gentlemen, I am at an impasse on this project.

I hook the ReplayTV up to a Visual Basic program that I have written to read from the serial output it produces when it changes channels, reading at 9600,N,8,1. Here is what I get from VB which is always a 6 byte transmission:

ch13: 250,2,250,70,0,13
ch15: 250,2,250,70,0,15
ch70: 250,2,250,70,0,70

This looked great to me since the last two bytes are the channel code I am looking for. The last two bytes for ch256 are 1,0 and so it goes.

So, I am using a picaxe 18M2 and run the following code:

setfreq m8

debug
main:

serin c.1,N9600_8,b1
serin c.1,N9600_8,b2
serin c.1,N9600_8,b3
serin c.1,N9600_8,b4
serin c.1,N9600_8,b5
serin c.1,N9600_8,b6
debug

pause 20000
B1=0
B2=0
B3=0
B4=0
B5=0
B6=0
DEBUG
goto main



with the following result:

ch13: 250,224,250,0,248
ch15: 250,224,250,244,0,248
ch70: 250,244,250,244,0,244


It seems I should get the same result for both methods. What am I missing here. My goal is to read the channel number from the replay with the picaxe. Why would these not be the same codes? Is my program flawed. What am I missing?

Thanks, again for your insights on this. Dave
 

hippy

Technical Support
Staff member
It could be that the serial data is sent with too little time between bytes for the PICAXE to keep up. You could try reading all six bytes in one SERIN ...

SerIn C.1, N9600_8, b1,b2,b3,b4,b5,b6

And you can also increase the operating speed with SETFREQ and adjust the _8 which will make the PICAXE ready for each byte sooner.

If the 18M2 doesn't have the speed to keep up with the transmission you will have to go to using background receive on one of the PICAXE which supports it. PC's run faster and serial ports all handle background receive which is why they can keep up with most data streams no matter how fast.
 

dabineri

Member
Hippy, Just reading using one serin did it! I suppose that there is a lillte too much overhead when using separate statements.

Thanks so much for staying with me on this. Dave
 

dabineri

Member
Looking for Insights

Before I get too far down a wrong path, let me ask for suggestions. I plan to use the channel numbers to trigger a dedicated remote control for the satellite tuner. It is easy to just short the connections that correspond to each digit of the channel number but what interface circuitry might be best to consider? Ten relays, one for each digit? Best way to control the relays with a picaxe? Thanks for suggestions. Anything else I need to watch for? Dave
 

dabineri

Member
Looking for Insights

Using a Picaxe to trigger each of 10 relays, would it work simply to use a 4 to 16 decoder attached to a couple of ULN 2003's?

Are there issues with this that I may not have considered?

Thanks, Dave
 

hippy

Technical Support
Staff member
I recall using a 4-to-16 decoder and had the problem that as the inputs changed it wouldn't switch cleanly but passed through other values, had to use the enable line to control things, but the principle seems right.

The ideal solution would be to use a PICAXE to generate the IR signals needed to replace the remote but that is a project in its own right.
 

dabineri

Member
Hippy, Given that I cannot decode the IR, what are some alternatives to controlling 10 relays from the picaxe that might be more reliable than a 4 to 16 decoder?

Thanks, Dave
 

BeanieBots

Moderator
Rather than use relays, use analogue switches such as the popular 4066 quad switch.
The issue with a 4 to 16 decoder is that you must switch all outputs simultaneously to avoid glitches on undesired pins. To avoid that, simply use a PICAXE with enough IO lines. (probably smaller and cheaper as well).
 

dabineri

Member
Thanks, BeenieBots, great idea. When such a switch is closed will it trigger a button push on a remote control? How much resistance when 'closed'?

Thanks, Dave
 

BeanieBots

Moderator
About 60 ohms from memory but the datasheet will give you an exact figure.
There are different types available. The 4066 is just one I know off the top of my head.
 

hippy

Technical Support
Staff member
Given that I cannot decode the IR ...
Not the code from the replaytv player, but the code from the IR remote you are planning to control with relays which sends to the directv satellite box. This should be an easier task as you only have to replicate what the remote puts out when a key is pressed / relay is closed. So it's really just a case of putting highs and lows out with the right timing rather than decoding anything.
 

dabineri

Member
So the piaxe can drive the 4066 directly? I am looking at the spec sheet and it seems only to require micro amps to trigger the switch. Is that your understanding?

Thanks for the advice, Dave
 

BeanieBots

Moderator
Correct. You simply connect the PICAXE output direct to the 4066 control input.

The only significant difference between an analogue switch and a relay (besides on resistance) is that the voltage being switched must not be higher than its supply voltage or lower than its 0v supply.
Think of it like regular relay contacts with a resistor in series and diodes clamping to supply and 0v.
 

dabineri

Member
OK guys, I am in the home stretch.

I am using SERIN to collect serial in put form my dvr. What is the best way to program this knowing that the serial data could appear at any time? Which method will use the least power and not miss an incoming signal at a random time?

Thanks again for all the advice on this project. Dave
 

hippy

Technical Support
Staff member
I'd have probably chosen to use high-speed serial background receive but if it's in a form which can be read reliably by SERIN there's no reason not to use that.

I think you'll have to clarify on the "least power" question; the PICAXE uses such little power that you usually don't have to worry about low-power or power saving. If you do, you'll need a means to wake it up and not miss any data. We'll have to know more about the serial data for that.
 

dabineri

Member
Thanks to help from many of you, the project is up and running!

The problem was to allow a ReplayTV model 5000 (older) to communicate with a new DirecTv satelite tuner box. I tried IR first but just could not clearly decode the signals supplied by the DirecTv remote control. Fortunately the ReplayTV has serial output for controlling older satelite boxes. I discovered that the serial output was 6 bytes the last two of which code the channel number in base 256. So, I used a picaxe 18M2 running at 8MHz to wait for serial input and decode the channel number that it expects to record. I obtained a remote control from ebay for 5$ US and attached 10 pairs of wires that would, by shorting, be equivalent to pressing a channel digit button. I then used 3 4066 "switches' each controlled by one output of the 18M2 to "press the buttons". So now I can set the ReplayTv to record any channel and when it initiates the record, it sets the DigitalTV receiver to the correct channel and the correct program is recorded.

Thanks again to all who helped, couldn't have done it without your expertise. Dave
 

eclectic

Moderator
Thanks to help from many of you, the project is up and running!

Snipped to save space.

Thanks again to all who helped, couldn't have done it without your expertise. Dave
I'm not a TV watcher, but,
for the people who are
and for posterity,
can you provide your schematic and code.

e
 
Top