Loading...
Pages: 1 [2]   Go Down
Author Topic: [SOLVED] How to use a 2-pin crystal for IC clock?  (Read 839 times)
0 Members and 1 Guest are viewing this topic.
UK
Offline Offline
Edison Member
*
Karma: 45
Posts: 2289
What a host of balls she had seen: gaity, the brass buttons...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ah, I see what you mean now.  I would imagine from the node at the top of Rf - the output of the inverter.
Logged


Offline Offline
Full Member
***
Karma: 6
Posts: 135
Knowledge is proportional to the number of parts destroyed.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why don't you build the clock documented in the AY-3-8910 datasheet?

Or am I missing something?

Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 85
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh... I never saw there was a clock circuit in the Ay-3-8910 datasheet. Its in Section 4.2 (page 29)

What if I have a 4mhz crystal? The same values of R and C should work, right?

In my case, do I need to connect PIN 13 of the CD4013 to the ground? Because I don't need a clock on my microcomputer (Arduino)

Ok, tomorrow I'll try that!

Thanks, all!
Logged

Offline Offline
Full Member
***
Karma: 6
Posts: 135
Knowledge is proportional to the number of parts destroyed.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, the resistor and capacitor values should be the same, or at least close enough to work.

There's no need to do anything with unused CMOS outputs. However, all inputs must be held in a known state and that includes unused inputs to the inverter chip.

Don't forget to connect power to the 4069 inverter, pins 14 & 7; I notice it's not shown in the datasheet.

You might also consider adding another flip flop / divider in the clock (use the other half of the 4013) to reduce the frequency down to 1 MHZ. I worked with these chips a couple of decades ago and found that at 1 MHZ the noise generator was a bit less 'harsh' sounding and the highest generated tone frequency dropped from 125 KHZ to 62.5 KHZ, which is still something only dogs and bats can hear.

Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 85
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, that's some useful information... from what I see on the clock circuit in the AY-3-8910 datasheet, I should connect PIN 13 to the PSG to get 1mhz.
I have a 4mhz crystal, so PIN 1 should get an output of 2mhz and PIN 13 an output of 1mhz in my case.

Can't wait the store gets open so I can buy what I need! I already have some coding to test a tone.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 85
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

NEED HELP AGAIN!
Ok, I did the clock circuit like the one on page 29 of the Ay-3-8910 datasheet: http://www.michael-george-hart.com/articles/computerscience/AY-3-8910_8912-Programmable_Sound_Generator.pdf
Difference is that I used a 4mhz crystal, and PIN 13 (after the inverter) goes to the PSG (in order to get 1mhz) and PIN 1 goes to PIN 11 because I don't need it's 2mhz output, no other output.
Also, I used a 330ohm R (instead of 300ohm) and 22pF capacitor (instead of 20pF) but that shouldn't be a problem, right?

Now, I think it is not working, if I connect the output to an Arduino PIN and do a Serial.print(digitalRead(1)) the amount of 0's and 1's I get is not even, for instance I get:

00110001100111 and so on...

Is there another way of testing if it works?
I followed the write and read procedures as majenco told me on another post (http://arduino.cc/forum/index.php/topic,114412.0.html) but it's not working right, and of course there is no sound coming from the channels. If it's useful I could paste some code to check if it's right.

Help?? Thanksssssssss!
Logged

Offline Offline
Full Member
***
Karma: 6
Posts: 135
Knowledge is proportional to the number of parts destroyed.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, let's see what I can help you with. I no longer have access to any 8910 chips so this is off my memory and the data sheet. Please forgive any confusion.

First, you can't assume that reading the clock in that fashion will work. The fact that you are seeing both 1's and 0's indicates that the clock is probably working.

By using the Serial.print() function, you are able to take (at most) the same number of readings per second as the baud rate divided by 10. (assuming 8 data bits, 1 start and 1 stop bit)

So 9600 baud / 10 =  960 readings per second.

And since there's some overhead processing going on, it's actually somewhat less than that.

But your clock is 1 MILLION Hertz and changes state 2 million times each second. (1 million 1's and 1 million 0's) By the time you take one reading, print it out and go back for the next reading, the clock has changed approximately 2083.333... times. (2000000 / 960)

Statisticly, if you were to measure the number of 1's and 0's over a long period, they would probably be close to equal in number. Short term, however, you may get three 1's followed by two 0's followed by four 1's followed by five 0's...

It looks random, and to a certain extent it is because you're somewhat randomly choosing when to read the clock with no idea if you are reading it at consistantly regular intervals.

My guess is it's probably OK.

Now, the PSG chip.

Double check that your grounds are common and all input pins are in the correct state.

A8      (pin 25) should be pulled HIGH
~A9     (pin 24) should be pulled low
~RESET  (pin 23) should be HIGH

Yes, I know the 8910 is supposed to have internal pullup/pulldown resistors on those pins. I've never trusted them. And Section 2.3 recommends that A8 and ~A9 be tied to VCC and Ground, respectively.

(BTW, ~A9 is how I write the name of a low true signal, since I can't put a bar over the word on the computer)

A8 and ~A9 are very important, because without them the chip isn't enabled and won't accept data from the computer.

Your connections to the Arduino should be similar to Figure 11 in the data sheet, 8 data lines and 3 control. It's also possible to control the chip with only 2 control lines, see Section 2.3



Next, I would see if I could write to and read from a register. If you can't do that, there's probably something wrong either with your wiring or code.

As a test, you can also write to the I/O ports and check them for operation. Don't forget to set them for output in register R7.

You did remember to enable the tone outputs in register R7, didn't you? And set the amplitudes to a non-zero value in R10, R11 and R12? Just checking, it's easy to overlook things; there's a lot to set up just to make it go 'beep'.


Software-wise, I believe Majenko is correct. There is a possibility that the Arduino is too fast for the PSG and you might need to delay a bit after writing to the chip. The delay would go between any write operation (INTAK, DWS) and the following NACT instruction. The read and write pulses need to be at least 500 ns in length for reliable operation so you might need a delay there as well. 

It would be best if you could get all the control pins to change at the same time.  When I was working with these chips, everything was interfaced to an 8 bit port, written to at one stroke.


For a simple tone test, I'd try writing the following data to the chip registers:

R1:    0000 0000       
R0:    0011 1110        (1000 Hz)
R8:    0000 1111       (Maximum amplitude)
R7:    1111 1110        (turn tone on)


For a 1 MHz clock, this should put out an approximately 1000 Hz tone at full volume on channel A.

Sorry about the delay at getting back to you, I'm working out of town and have intermittant access to a computer.









Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 85
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks a lot for that long and detailed reply, it was very helpful!!!
Now I understand why were the readings like that, so let's suppose that the clock works.

Quote
Your connections to the Arduino should be similar to Figure 11 in the data sheet, 8 data lines and 3 control. It's also possible to control the chip with only 2 control lines, see Section 2.3
Next, I would see if I could write to and read from a register. If you can't do that, there's probably something wrong either with your wiring or code.

The connections between PSG and Arduino are like that, and I already tied BC2 to +5v, so I already use only 2 control lines.

YOU KNOW WHAAAAAAT??? I tryed again with your test tone and it WORKS!!!

I will paste entire and corrected code on this post: http://arduino.cc/forum/index.php?topic=114412
Logged

Pages: 1 [2]   Go Up
Print
 
Jump to: