PDA

View Full Version : Oscillator/Clockout



fowardbias
- 22nd February 2006, 02:35
I need to drive a motor driver chip with a PIC and can't decide the best way to go. The driven chip needs its own oscillator (input pin) along with a strobe, clock, and data lines. Should I run the PIC with INTRC_OSC_CLKOUT, using the PIC clockout as the clock input to the chip? OR: Use two oscillators, one would drive the motor chips osc.pin and the other would drive the PIC and clock input of the chip. This would run in EC_OSC with the PIC. Looking for the better way, always. JS

sougata
- 22nd February 2006, 04:54
Hi,

It would be better to know the chip and comment.

Regards

Sougata

Dave
- 22nd February 2006, 11:54
fowardbias, Yes you can use the oscillator from the pic as the master oscillator in your circuit if you use the external oscillator drive circuitry for the pic. However I would buffer the oscillator from the pic output pin as to not load the oscillator circuitry for the pic.

Dave Purola,
N8NTA

fowardbias
- 22nd February 2006, 16:56
The PIC is 16F628 driving The Allegro A3958SB H-Bridge. The serial input uses three lines for input: strobe, clock and data. The bit stream is 20 bits wide and doesn't fall into a structure (no defined baud rate or parity). Each of the bits along with a few other external pins defines what the chip does. Details of this is on their web site. I haven't got to the breadboard stage yet, only planning. Later J.S.

sougata
- 23rd February 2006, 05:13
Hi,

The datasheet says that the oscillator input freq. range is between 2.9 and 6.1 MHz. So using the internal oscillator @ 4Mhz will give you a clock out at 1MHz.(Instruction cycle clock). You can use an external crystal oscillator @4MHz and buffer the oscout pin to feed into your allegro chip. Since the data is 20 bit MSB first, the possibility of Shiftout rules out. Keep the different controls in different bytes and use your own routine to dump the data. It should be easy in a for-next loop doing a clock toggle at around 100uS and dumping the databits. Since each instruction clock cycle at 4MHz takes 1uS it will be better to use a slower clock so that your overall timing are not effected by other tasks (like getting individual bits and dumping to the data line). Remember to start the operation with the Strobe line.

Regards

Sougata

Dave
- 23rd February 2006, 11:50
fowardbias, I don't know what sougata is talking about, Yes you can just use the SEROUT command to shift out as many bits as you like. You just need to break it up into something usable such as 2 bytes and 4 bits or 1 16 bit word and 4 bits as long as the largest variable is no longer than 16 bits. I do it as such:
SHIFTOUT UCN_DATA,UCN_CLK,MSBFIRST,[OUTPUTS(1)\4,OUTPUTS(0)\16]
PULSOUT UCN_STB,PULSE 'STROBE UCN5832A DATA LATCH
With this type of device the data is "clocked" in so it does not matter if there is a slight pause between the data bits.

Dave Purola,
N8NTA

sougata
- 23rd February 2006, 18:15
Hi,

Yes it is possible with PBP to throw out data bits the way dave said but I have never used it. For a motor control app a glitch may cause problems and I personally never take chances. If I get some time I would like to disassemble a shiftout code and get the total picture on the clock idleing issues.Hope dave can give some deeper insight.

Regards

Sougata

fowardbias
- 23rd February 2006, 19:26
Dave, like you this is where I was going with this since the Shifout command is setup for this purpose. Thanks for a code example.

Sougata, I'm sorry I didn't follow you with the for next loop being used as a way of bit dumping, maybe I just don't see how the loop combines counting to data pin output. It probably can be done with more code but the Shift out command is ready to use.

Thanks to both for your ideas. J.S.

Dave
- 23rd February 2006, 21:23
fowardbias, There is not a problem as the data is not updated untill you issue the strobe at the end of the shiftout. Just don't send 1 byte then go and have some breakfast then send the rest of the message. I haven't seen more than a fraction of a millisecond delay between the variables being shifted out using this method.

Dave Purola,
N8NTA