I'm cryin' For Help

vk6bgn

New Member
Hello PICsters,

Yes I need a bit of help. But just a bit of history first. I decided some time ago to have a go at a PICAXE project from the ground up. Design, art work, etching the circuit board and programming the PICAXE. I also decided to try and build something that was not already posted all over the internet. And of course Amateur Radio related!

The project is a repeater controller board to control two VHF radios to be used as a repeater using a PICAXE 18X, a MC145436 DTMF decoder chip for remote control and programming and a LM358N in the audio section. This is just standard stuff as there are at least a half dozen of these designs on different Ham Radio operator’s web sites using a PIC16F84 chip but all seem to use .bin or .hex or .asm files. All those files are just to much for me. So hence the PICAXE! Also the curiosity to see if the PIAXE is up to the task.

The set up here is: Computer running a DTMF program, PC speakers with an earphone jack with the audio (DTMF tones) patched into the “Receive Audio” on my circuit board.

Problem #1…. I ran out of inputs! Lol. Haven’t we all heard that before! Correct me if I’m wrong, but the 18X has only 5 inputs? Actually, I didn’t realise this until after the board was etched and all parts were soldered on. The DTMF chip has 5 outputs. Four Data bits, D1, D2, D4, and D8 and a Data Valid pin to indicate that a valid DTMF tone has been received. I did use this pin to activate a LED and this is very helpful. But it really should have ALSO gone to an 18X input. I think it would make things easier. But the last input on the 18X was for the COR or CAS. This is an input from the receiving radio to tell the 18X that the squelch is open on the receiving radio and it is now receiving a signal. I think this should be solved by polling the inputs with something like:

If Input0 = 1 OR Input1 = 1 OR Input6 = 1 OR Input7 = 1 then GOTO GetDTMFTones

I think this solves this but maybe there is an easier way to detect that someone has pressed a button on the DTMF keypad and some or all the data pins are high on the DTMF chip.


Problem #2 (and a problem I can’t solve.)
First of all, I want to write the first three DTMF keypad presses to the EEPROM location and the next 3 keypad presses is the data I want to write to it. All in six consecutive key presses. So far, so good. Most of the data will either be the number 0, 1 or 2 to generate the call sign when it ID’s in Morse Code. Not the best way by no means but the easiest that I can think of for simplicity reasons. There’s no Hex to ASCII conversion charts required to program the 18X. All EEPROM memory locations 0 – 255 and the data to go in them are decimal. Right? But I would like to be able to change the tone for the speaker output which is a constant and set at 112, approx. 1000Hz. I think? So I would be required to write numbers three digits long for the data. It doesn’t matter to me if I have to write to EEPROM address 005 with three key presses of 0,0, and 5 or location 87 as 0, 8, and 7. This is fine. And for the data, it can be the same way too. The number 2 can be key presses 0,0, and 2. It doesn’t have to be just the button #2 only. Unless it’s easier to program. But I can’t figure it out.

As you can see in my not so clever code, When I write to EEPROM, b7 = b1 + b2 + b3, this just adds them up. It doesn’t make a 3 digit number!!! So the highest possible number from 0 – 9 is 27 for the memory location in EEPROM to write to and the largest number to be written to it, is also number 27. There is a bit of a work around. B7 = B1 * B2 *B3.

But this is cheap and nasty and takes away the “simplicity”. Also, possibly not all 0 – 255 EEPROM memory locations would be available? Could you write the number 250 to EEPROM location 250??? I’ve toyed around with this for two nights burning the midnight oil and I’m cryin’ for help!

Beware, all the mumbo jumbo in the code to change a DTMF key press for byte b0 from one number to another is due to the DTMF chip data bit D1 going to Input7 on the 18X. This generates a number 128 in the PICAXE. Or D8 going to Input0. This generates a number 1. etc. etc. It took me two evenings to figure that out! But it was a learning experience.

I’m sure you know what I’m after, it’s three consecutive key presses to equal one complete number. I’m sure you know what I mean.

Sorry for the huge post. Just trying to let you know exactly what I’m trying to accomplish.

Cheers,
The “HamRadioAddict”


Code:
Symbol Callsign = b13
Symbol Letter = b12
Symbol IDLed = Output5

 
EEPROM 60, (2,0,1,0,2)            '"K" (sends the letter K as per below)

Start:
If b7 = 58 then goto Key      'Forces the call sign to play after it's all programmed! That's if I could get B7 & B8 bytes higher then
                              '27 to be properly programmed 

GetFirstDTMFTone:
Gosub GetDTMFData
b1 = b0
b0 = 0 
Debug b1

GetSecondDTMFTone:
Gosub GetDTMFData
b2 = b0
b0 = 0
Debug b2

GetThirdDTMFTone:
Gosub GetDTMFData
b3 = b0
b0= 0
Debug b3

GetFourthDTMFTone:
Gosub GetDTMFData
b4 = B0
b0 = 0
Debug b4

GetFifthDTMFTone:
Gosub GetDTMFData
b5 = b0
b0 = 0 
Debug b5

GetSixthDTMFTone:
Gosub GetDTMFData
b6 = b0
b0 = 0 
Debug b6


WriteData:
b7 = B1 + B2 + B3  '  <<<< problem here
b8 = b4 + b5 + b6  '  <<<< problem here too
Debug b7
Debug b8
Write b7, b8
 
For Callsign = 60 TO 64      'Sends the the letter "K" to the speaker to say all 6 DTMF consecutive key presses have been received  
     Read Callsign, Letter   'and a write to EEprom is done. Otherwise key it in again. 
     Gosub Bangkey
     Next

goto start

 

GetDTMFData:

WaitForValidData:
b0 = Pins
b0 = b0 AND %11000011            'Masks out the input pin "In2", physical pin #1
If b0 = 0 THEN WaitForValidData


If b0 = 1 then gosub ChangeByte1 'please explain.... it's here cause the DTMF data liones go to the wrong pins and generate the wrong numbers
If b0 = 2 then gosub ChangeByte2
If b0 = 64 then Gosub ChangeByte64
If b0 = 65 then Gosub ChangeByte65
If b0 = 66 then Gosub ChangeByte66
If b0 = 128 then Gosub ChangeByte128
If b0 = 129 then Gosub ChangeByte129
If b0 = 130 then Gosub ChangeByte130
If b0 = 192 then Gosub ChangeByte192
If b0 = 194 then Gosub ChangeByte194
Return


ChangeByte1:
b0 = 8 
Return
ChangeByte2:
b0 = 4
Return
ChangeByte64:
b0 = 1
Return
ChangeByte65:
b0 = 9
Return
ChangeByte66:
b0 = 5
Return
ChangeByte128:
b0 = 2
Return
ChangeByte129:
b0 = 0
Return
Changebyte130:
b0 = 6
Return
ChangeByte192:
b0 = 3
Return 
ChangeByte194:
b0 = 7
Return



Key:

For Callsign = 0 TO 58   'Takes a maximun of 59 EEprom locations for the largest repeater callsign, but usually smaller, around 50ish
     Read Callsign, Letter
     Gosub Bangkey
     Next

Bangkey:
	Branch Letter,(Space,Dot,Dash)
      Return
	
	Space:
            Sound 1, (0,6)
            Return

	Dot:
	    High IDLed
            Sound 1, (112,6)
	    Low IDLed
            Return

     Dash:
            High IDLed
            Sound 1, (112,18)
	    Low IDLed
            Return
 

Attachments

Last edited:

westaust55

Moderator
PICAXE for Amateur Radio

For problem 1:

Presuming you do not want to modifiy the hardware to add a shift register to get more inputs one potential solution is the polled interrupt.

If the four inputs will always be 0 until there is valid data, you could use the polled interrupt command and routine to action the data entry.

SETINT %00001111, %00001111 ; will go to the interrupt routine if any of the first 4 inputs are a 1.

Then call the data entry routine Interrupt:

When you have stored the data you need to have the SETINT command again preferrabley just before the RETURN statement. Otherwise the interrupt is cancelled when you enter the interrupt routine and never acts again.

For problem 2:

you can only get the sort of number you are looking for ( a 3 digit decimal value from 000 to 999) if you use a word variable (16 bits ==> values up to 65,535) instead of a byte (8 bits ==> max value is 255).

The WRITE command can only accept a byte for the location. However it CAN accept a word as the data to store. So while there is no nice easy fix for the location but for the variable can be just as you want.


You say that the digits are normally 0, 1 or 2.
If your first 3 digits never had a first digit greater than 2 and second/third digits greater than 5 then
b7 = b1*100+b2*10+b3 would work but I doubt the digits you receive will allow it to be that easy.

For the data to be written, you seem to have a couple of spare byte variable to create a word. keeping in mind w0 = b1 and b0, w1 = b3 and b2 etc. so you could use:
W5 = b4*100+b5*10=b6 ; w5 variable uses byte variables b11 and b10.

And then

WRITE b7, w5
 

eclectic

Moderator
Addict.

I can't find the postings at the moment, but Hippy has posted several
hints on this.

Three key-presses say b0, b1 and b2

The principle is....

w2 = b0 * 100
b1 = b1 * 10

w2 = w2 + b1 + b2

Obviously, it can be made more elegant.

Or have I missed something (as usual)?

e.
 

vk6bgn

New Member
Thanks westaust55 and eclectic.

All sorted out now. It’s been painful the last few evenings trying to figure this out. Especially for something that was so simple. Had me stumped. If Hippy has posted this before, he must be hoarding it cause I couldn’t find it. Lol. I searched for a better part of 2 hours looking for a solution. On and off this site.

Thanks for the help.

Cheers,
The “Addict”
 

vk6bgn

New Member
Davidwf,

The program I'm using for circuit board artwork is a program called "Sprint Layout". I think it comes out of Germany. In my frugal nature, I was looking for something cheap, basic features and only needed to do single sided boards. After searching the net, I settled on this one. It actually does a lot more then I require for back yard projects and it was only 40 Euros. I paid via Bpay. Their online form asked me a few questions and then I acquired the software online. It has it's own file type but exports in most all the standard types. Gerber, .bmp .jpg .gif and even a file for a CNC milling machine. Oh, I think the max size board is 300mm x 300mm.
 
Last edited:

vk6bgn

New Member
Hey westaust55,

I've been reading about that just last night for a couple hours. Some posts by "Hippy" and others on this site. Plus also trying to study the data sheet for the 16F88 chip. Like 225 pages! Thanks for the link to the old post on this subject! Very helpful!

The pin in question on the PICAXE 18X that I would like to change is physical pin 6, Picaxe pin OUTPUT0.

What I'm using OUTPUT0 for, is an output to drive a MFP102 J-FET to be used in a simple audio "mute" circuit. No problem with this. But what I also need to use this pin for is a "first time power up initiation". This would check the output, now a new (temporary) input and check to see if there is 0 or 5 volts on this pin. 0 volts means there is an initiation jumper in place on OUTPUT0 (now an input) to ground. There is actually 5 volts on this pin. See attached diagram. Anyway, this jumper would be put on at the "very first time&#8221; on "power up". It will force the human (me) to then enter a 3 digit passcode via DTMF tones. But not on every power up. Only the very first time power up or if I want to re-initialise and enter a new pass code at some other time. I&#8217;ve seen the same Output - Input thing done on another circuit, but with a 16F84 on physical pin 3. Not on a 16F88. I have yet to look at the 16F84 data sheet either.

My only worry is what happens if OUTPUT0 is being used as an output to the MFP102 J-Fet to pass or mute the audio and I put on the initialising jumper? Poof!?!?!?

One person I corresponded with told me that this could be done as the Output is an &#8220;Open Collector&#8221; circuit and wouldn&#8217;t harm anything. So Goggling "Open Collector Circuits" tonight. But I&#8217;m not game to try and smoke test my 18X chip. (yet)

Your thoughts. Or anyone else&#8217;s comments who maybe knowledgeable about this.
 

Attachments

Last edited:

hippy

Ex-Staff (retired)
STOP

I’m not game to try and smoke test my 18X chip. (yet)
You may well fry your PICAXE with that circuit. You cannot drive an output through a link to 0V, and a default output will always be an output at reset and (probably) during download even if re-configured later.

No reason this technique won't work though if you make it fry-proof, but I'm not sure how to do that with that circuit.
 

BeanieBots

Moderator
It should be possible to make that circuit failsafe (as far as the PICAXE is concerned) simply by adding a schottky diode (pointy end to PICAXE).
With the link removed, the 1k will pull-up and drive the transistor when output is high. When the output is low, current will flow through the diode and reduce voltage on the base drive resistor to around 0.3v. For a 'normal' transistor, that will be low enough to prevent any base current from flowing (~0.6v typ.). If the transistor is a very hfe type, then you might need to add a second diode in series with base resistor (pointy end to transistor) and a high value resistor (100k) between base and 0v.
 
Top