|
|
View previous topic :: View next topic |
Author |
Message |
djsb
Joined: 29 Jan 2011 Posts: 41
|
|
Posted: Sun Dec 18, 2022 1:22 pm |
|
|
Thanks Temtronic,
I've corrected the BIFSC to BTFSC and put the equivalent instructions for SKPC,SETC, CLRC as mentioned in the datasheet. It's good to get more eyes on the code so that mistakes are found that I missed. Got to go and read my assembly language tutorials during the week. Last time I did any PIC assembly was over 5 years ago. Mostly been using CCS C since.
David. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19540
|
|
Posted: Mon Dec 19, 2022 3:20 am |
|
|
Big caveat here.
You can't just adapt that code. You need to rethink the circuit approach.
If you look at the data sheet, you will see that for the 16C50, they are
driving the data line directly, and reading from the same pin. However
immediately below in the circuits for the 6800, they instead have two
lines used for this, with a transistor used to give an open collector drive
from 12v to drive the pin, and a separate transistor used to bring the
signal 'back' to another pin. All of the output signals are connected
via transistors.
This is the circuit you have to use to do this with a PIC. This was basically
what we had to use with the Z80. You need the buffer transistors on all
the outputs, since the PIC cannot drive a 12v signal directly, and you
need the separate one for the input signal for the same reason.
The 16C50 has open collector outputs that support being taken up to
10v. The modern PIC's do not allow this.
The code will need to be tweaked to read the data from a separate pin.
It is honestly not worth trying to adapt this. Just re-write it. The operation
is very simple.
You cannot just substitute a modern PIC into a circuit that used the
16C50. You need an adapter board to do this. I suggest you look at the
circuit example for the 8048, since the supply voltages are slightly easier
than for the 6800 circuit.
Last edited by Ttelmah on Mon Dec 19, 2022 6:41 am; edited 1 time in total |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Mon Dec 19, 2022 6:40 am |
|
|
possible solution ??
http://www.keeelectronics.com/JDM_setup.html
As the goal is to read/write the ER1400, this 'programmer' should work.
....providing you've got a PC with a real comport AND you can find the JDM programmer.......
might be worth contacting the company. if they're still around, they might have a dusty shelf of them they want to 'relocate'. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19540
|
|
Posted: Mon Dec 19, 2022 6:43 am |
|
|
What makes you think that is any use?. It can't handle the 35v supply
the ER1400 needs.
The ER1400, uses a 35v supply. The circuit that is needed to talk to it
from a PIC, is a 'cheat'. You supply the ER1400 off 12v. Have the PIC
running off the ground from this, with it's own 5v supply. Then have -23v
for the 0v pin on the ER1400. Then have external driver transistors between
the PIC and the ER1400 pins. That way the inputs to the ER1400 can be
driven to the 0v, by turning a PIC pin on or let go to +12v by turning the
PIC pins off. This meets the input requirements for the ER1400. The data
output will need a voltage divider, and feed another pin on the PIC (ideally
the input transistor as shown on the example circuits).
The code on the PIC then will need to be inverted from what it shown in
the example code, and need to be using another separate pin for the
data input.
So the board is going to need three supply rails (+12, +5, and -23v), to
drive the chip. The 16C50 circuit uses +10, +5, and -25. You could use
these voltages.
The code can be adapted easily enough, but his hardware also needs
to be different, because of the differences between a modern PIC and
the old device. Just because it contains the three letters PIC, doesn't
make it even remotely compatible with the modern devices..... |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Mon Dec 19, 2022 7:01 am |
|
|
I'm just going by the datasheet that says ER1400.
There's an orange5cnc programmer that has an SMT parted adapter for the ER1400, and 'somewhere' I found the schematic for that. Wished I'd saved THAT link.....
I know my Needham's PB-10 doesn't list ER1400, just grabbed the manual for it.
Curiously, just looking for options.
Since this is slow speed, perhaps some opto-couplers will work. I use them to convert TTL into +-60 volts transmit data, as well as read incoming current (<10ma). |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19540
|
|
Posted: Mon Dec 19, 2022 7:49 am |
|
|
Yes, that it why I was thinking about the MOSFET gate drivers. Could
simplify the interface massively. Removes the need for so many different
rails, and makes the drive a lot simpler.
I'm guessing the JF may be able to program the ER1400, with some special
adapter to handle the voltages. It does talk about adapters, but no details
seem to exist. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Mon Dec 19, 2022 7:52 am |
|
|
finally.....
http://www.cnc-lab.com/orangshme.htm
only took an hour to find ,again....
1/2 way down....
real schematics !!!
still not clear HOW they actually read the ER1400 though..... |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19540
|
|
Posted: Mon Dec 19, 2022 8:06 am |
|
|
Makes total sense. Six transistors, external 35v supply, and a zener
to give the level setting between this and the programmer supply.
Exactly the type of circuit needed for this.
However it is also 'interesting', since they are only pulling the control
lines down to -5v relative to the 35v supply. The data sheet says they
need to go down to -8v. That it works, suggests the data sheet levels
may be a bit flexible..... |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19540
|
|
Posted: Mon Dec 19, 2022 11:02 am |
|
|
Now, completely untested. Probably some errors, but based on what the data
sheet shows, and assuming one wires as for the 6800, with the C1, C2, C3
DATA & CLOCK lines all wired with pull down transistors from 12v, and an
input wired using a separate transistor to 5v.
I'd suggest using the voltages shown in the 8048 circuit.
Code: |
#include <18F45K20.h>
#device ADC=10
#FUSES NOWDT //No Watch Dog Timer
#use delay(internal=32000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=PORT1)
//Now setup a timer
#use timer (timer=1, tick=1uS, bits=16)
#define HALF_CLOCK 35
#define WHOLE_CLOCK 71 //usec intervals for the clock pin
#define ECLK PIN_A0 //clock pin
#define C1 PIN_A1 //3 command bits
#define C2 PIN_A2
#define C3 PIN_A3
#define EDATAO PIN_A4 //Output pin
#define EDATAI PIN_A5 //Input pin
//Be aware, you are going to have to use the interface shown for the 6800
//microprocessor, not the one they show for the PIC16C50. With separate
//data out and data in lines. This is because of the different voltages
//supported by the chips.
//Be aware the EV chip uses -ve logic. It sees a signal as '1', when it is
//pulled down. So with the inverting transistors in the circuit our signals
//need to use +ve logic. A '1' at the PIC is a '1' at the clock etc..
//Note that it shows the clock having to continue for the whole of the
//write time and erase time.
#define logic0(x) output_low(x)
#define logic1(x) output_high(x)
void clock_bit(void)
{
set_ticks(0);
logic0(ECLK);
//Just delay for one bit time and raise the clock in the middle of this
while (get_ticks()<HALF_CLOCK) //wait for 1/2 clock time
;
logic1(ECLK);
while (get_ticks()<WHOLE_CLOCK) //wait to the end of the clock
;
logic0(ECLK); //important, leaves clock high at chip.
//C lines can only change when this is the case
}
void long_clock(void)
{
//Now need to maintain clock till cycle has completed. Says 15mSec typical.
//example code shows 18mSec.
int16 count;
for (count=0; count<256; count++)
clock_bit();
}
void standby(void)
{
//switch chip to standby
logic0(C1);
logic0(C2);
logic0(C3);
logic0(ECLK);
}
//generic 'clock data' routine. Sends 'number' bits from data
void etran(int32 data, int number)
{
int bitno=0;
//clock data to the chip. LSB first
do {
if (bit_test(data,bitno))
logic1(EDATAO);
else
logic0(EDATAO);
bitno++;
clock_bit();
} while (--number>0);
}
//Now similar to clock data in from chip
int16 eread(int number)
{
int bitno;
int16 tick;
int16 data=0;
bitno=number-1;
//clock data from the chip. LSB first
do {
if (input(EDATAI)==0) //since this has a transistor, inverted
bit_set(data,bitno);
bitno--;
clock_bit();
} while (--number>0);
return data;
}
void send_address(int address)
{
int32 addr=0;
int decimal;
//now need to convert a standard number into a two digit value.
//one of ten encoding for each digit.
decimal = address/10; //upper digit
bit_set(addr, decimal+10); //single bit
decimal = address-(decimal*10); //lower digit
bit_set(addr, decimal); //Now low bit
//Now have the one of ten value. Send this to the chip as address
logic0(C1);
logic1(C2);
logic1(C3); //011 on the control bits
etran(addr,20); //send 20 bit address
}
int16 read_word(int address)
{
int16 word;
//Now sequence is shown as send address, then change C lines, to 100,
//then send one more clock, then set C lines to 101, and shift the data out.
send_address(address);
logic0(C1);
logic0(C2);
logic1(C3); //set 100
logic1(EDATAO); //turn off output transistor
clock_bit(); //this copies data from memory to the shift register
//Now shows 101 for the actual shift
logic1(C1);
logic0(C2);
logic1(C3); //set 100
word=eread(14); //read 14 bits
standby();
return(word);
}
void write_word(int16 value, int16 address)
{
//here sequence is send address, then write data to shift register (111)
//finally trigger write (110). Maintain clock for the whole write time.
send_address(address);
logic1(C1);
logic1(C2);
logic1(C3); //set 111
etran((int32)value, 14); //clock 14 bits to the shift register
long_clock(); //clock till complete
standby();
}
void erase(int16 address)
{
//erase the 14 bit word at address
send_address(address);
logic0(C1);
logic1(C2);
logic0(C3); //set 010
long_clock(); //clock till complete
standby();
}
void main()
{
logic1(EDATAO); //turn off output transistor
logic0(ECLK); //They show the clock starting low.
standby();
while(TRUE)
{
//Now you will need to add some form of serial I/O to allow you to send
//an address and data, and see if it works.
}
}
|
This could be moved to almost any PIC and clock rate.
Changed this. Realised I was clocking the input data in reverse into the
received word.
Last edited by Ttelmah on Wed Dec 21, 2022 1:10 am; edited 1 time in total |
|
|
djsb
Joined: 29 Jan 2011 Posts: 41
|
|
Posted: Mon Dec 19, 2022 2:17 pm |
|
|
Thanks for the code Ttelmah,
Much appreciated. It will take me a while to understand. I'll have to have a look at the 6800 circuit that you mention.
The Revox B261 uses transistors and a SAA1061 port expander
https://www.eevblog.com/forum/microcontrollers/how-does-this-old-er1400-earom-work/?action=dlattach;attach=1665331
Maybe I can copy that?
Maybe simpler to just stick my logic analyser on the pins to try and understand what the EAROM stores. I'm guessing a station's frequency, which button preset is pressed, and any station identification characters.
I'm beginning to wonder if I can just get rid of the external EAROM entirely and just use either an external EEPROM or the internal EEPROM of a PIC? Maybe the 14 bits can be spread over 2 x 8 bits with 2 don't care bits. Just thinking aloud. I'll have a think over the next few weeks on what my approach should be. No pressure as this is just a hobby project.
In the meantime, I'm going to stick a new EAROM (and a DIP socket) on the MCU PCB and hope that improves things a bit (tuning jumps around a bit). Thanks for all of your help so far and have a nice holiday. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19540
|
|
Posted: Tue Dec 20, 2022 11:17 am |
|
|
A PIC with internal EEPROM would be vastly easier. One with a standard
external EEPROM would be almost as easy.. You immediately get rid of the
need for all the transistors, and the complex power supplies. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Tue Dec 20, 2022 11:34 am |
|
|
I keep coming back here, trying to think of 'options'.... found this....
https://elektrotanya.com/revox_b261_serv.pdf/download.html#dl
which has a nice schematic of your 'project'.....
I'm thinking it might be easier( ? ) to program a PIC to 'emulate' the ER1400.
As others have said it ELIMINATES the 'nasty, complicated' level shifting details.
If the SAA expander is in a socket, a mother/daughter board could be made, where the SAA chip is inserted onto a PCB that also has the PIC, and the PCB goes into the original SAA socket.
It 'should' be easy to code the PIC to emulate the ER1400 as all the details on how it works are known. I'd save the data into RAM and not the EEPROM, for now. Nice thing is the PIC is a LOT faster and with enough I/O pins, you could keep the ICSP pins for easy upgrades, any 18 pin PIC should work ?
While this doesn't allow you to read the real ER1400, the PIC RAM data WILL be true data and easy to dump out, say via a spare pin as 'RS232'. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|