4014B PISO shift register with Serin

atharvai

Senior Member
Hi, I've read about using shift registers (8-bit PISO 4014B)with PICs on this forum. I understand that the serin command needs a start and stop bit. this would need 10-bits in total. I have the register working on its own fine shifting 8 bits using a 4kHz clock. a few questions:
1) is the clock correct for the baud rate of the serin command
2) how can i add the start stop bits to the word without using another IC and with minimalistic components. (is this possible?)
my deadline is monday (23 April).

any suggestions or thoughts welcome
Thanksin advance
 

leftyretro

New Member
Well I would certainly defer to more experianced posters on this but I think you are off on the wrong track. First I don't think any picaxe chip at any speed could read a 4 mhz clock rate through it's serial input function. Second, why fiddle with serial input channel anyway, just bit bang your shift register data via a pic digital input pin, using a pic digital output pin to clock the device? Might need another pic output pin to control the mode of the shift register, I couldn't find a data sheet for your shift reg.

Lefty
 

atharvai

Senior Member
FYI I'm using a 4KHz not 4MHz.
also i have to use a shift register for PISO conversion. (i have to limit my use of PIC for my coursework)
at the moment the PIC reads a number but (i reckon) not a 8 bit number.
 

Jeremy Leach

Senior Member
Hi, I think it would help to understand what the objective of your assignment really is first.

Also, there's quite a lot of complexity going on in serial comms that's taken care of at a low level in the Picaxe with the Serout and Serin commands. For starters the sender and receiver don't share a common clock signal, so differences in frequency and phase need to be taken into account.
 

atharvai

Senior Member
an 8-bit output from a ADC is taken and inputed to the 8 parallel inputs of the shift register. This is then outputted serially so the PICAXE. Can i change the clock of the shift register to match the baud rate of the PIC, if so what clock do i need?
neway the PIC reads the input every second (I need the PICAXE to read the input every second no more frequent readings are needed).
 
G

Guest

Guest
"FYI I'm using a 4KHz not 4MHz."

Yea I blew that one didn't I ;-)

So speed won't be a factor at 4khz. I still think 'bit banging' the data into the pic is more partical then adding hardware to your interface just so you can utilize the serial input command. Is that a requirement or part of the specification? If so, you will have to add extra logic to simulate the start and stop bits. Also you are going to have to add timing triggers to initate the transmision of the data to the pic @once a second, as the serial in command will just be waiting for a start bit, forever.
 

hippy

Ex-Staff (retired)
How are you clocking the shift register ? If from a PICAXE output line, simple read the data in on the PICAXE input after you clock it. Having clocked it 8 times you will have the bytes ready to use.

You can use 8-bit shift registers to create a serial stream suitable for SERIN, but only at 7 bits, you'd need two in series to do 8-bits.

It seems a lot of effort to go to if you don't need to.
 

Jeremy Leach

Senior Member
If I understand you correctly, you want to get the data from an external ADC into a Picaxe.

Using a Shift register is a good idea, but using the Serin command to get the data from the shift register isn't. I think I can see your reasoning though ... add the necessary start bit etc to the data, clock the shift register at the right rate and then use the convenience of the Serin command.

There are a few problems with this approach though, the main one being there's no easy way to add the start bit (and stop and parity) to the data in the shift register !!

However, extracting the data from the shift register by controlling the control lines of the chip by 'bit-banging' and reading the data output of the chip into a picaxe input would work.

You need to look at the datasheet of the chip, see how it is controlled and the get the picaxe to send the right control signals to get the data out. Put this code into a subroutine 'GetSRData' or similar, then call this routine every time you want a reading.

However there's also the external ADC chip - what triggers this to do a conversion?
 

hippy

Ex-Staff (retired)
<i>Can i change the clock of the shift register to match the baud rate of the PIC, if so what clock do i need? </i>

Is this part of course work ? In which case you should be able to determine what clock rate to use knowing the baud rates the PICAXE acepts. The clue is in 'baud rate', for the PICAXE, this is the number of bits per second which it expects to receive.
 

hippy

Ex-Staff (retired)
Jeremy : <i>there's no easy way to add the start bit (and stop and parity) to the data in the shift register </i>

A start bit simply requires wiring the first bit out permanently high, and wiring the stop bit permanently low ( or just keep idling after send for at least one bit time ). That would match an Nxxxx baud rate.

The only issue with such a scheme is that the SERIN will invert the actual data when received and has to be inverted back in software.

Edited by - hippy on 18/04/2007 00:11:52
 

Jeremy Leach

Senior Member
Ah yes, of course. I was thinking of the 8 bits of data in one 8 bit shift register and how add these bits on ! ...but yes 2 shift registers could work (if the other issues were solved).
 

atharvai

Senior Member
I've decided to use PIC28X. i've written the following program.

' Start of Program
let b0 = pins &amp; %11111111
'shift each bit through serout pin 4800-8-n-1
sertxd (b0)
wait 1
goto main 'loop
'End of program

Instead of &quot;let b0 = pins &amp; %11111111&quot; will &quot;let b0 = pins&quot; work?

Edited by - atharvai on 19/04/2007 19:55:26
 

hippy

Ex-Staff (retired)
<i>I've decided to use PIC28X </i>

&quot;PICAXE-28X&quot; - don't confuse the PICAXE with a PICmicro device.

<i>i'm not sure on the sertxd command </i>

That's what &quot;Manual 2 - Basic Commands&quot; is for.

<i>do u thin kthat another PIC will be able to read the serial number using serin. </i>

Another PICAXE will if you use an appropriate SERIN command which reads what you've sent and converts it back to a number in a format you can use, as long as it supports the baud rate you are sending at.

You don't have the most efficient mechanism for transferring a byte from one PICAXE to another but it should work. By reading the pins into bits of a byte variable you can form a single byte value which can be sent. By reading all pins together you can form that byte value in one step, one line of code.

As this is coursework I will leave you to research and experiment in that direction.

<i>are the start and stop bits added automatically? </i>

Yes, for both SEROUT and SERTXD. They would be near pointless commands if they did not do that.
 

atharvai

Senior Member
yes thanks.. I realised. i changed my program . i edited my previous post. i should really read the basic commands PDf first! sorry

sertxd works on PICAXE-28X i've used it before . so not worried about that

Edited by - atharvai on 19/04/2007 20:08:28
 
Top