How To Choose the Truly Correct OSCHS3, OSCHS2, OSCXT2, device setting?
![Zoot](https://forums.parallax.com/uploads/userpics/559/nW4UO23UEIWZ4.png)
Quick background: I installed my SX servo/led controller in my big 'bot. This is a 'bot that has run fine w/o code changes for 6 months or so. Used to have a PSC in it, which I replaced with the SX version.
Now, I spent all morning get SERIN failures (sporadically) on the host side when it would query the SX. At all baud rates. Board worked perfectly on the bench.
After much trial and error, I discovered that when the motors were OFF that everything would be fine. Motors ON = serial problems. I figured maybe it was noise, but it seemed weird because the PSC (at same baud rates, exact same wiring, power supply, etc) was fine for the nearly 18 months it was installed.
In any case, it seemed like noise would be the culprit, and a single battery supplies all power systems, but I couldn't find anything amiss on the serial line with a scope, no brownouts, etc.
I decided to try a 20MHZ resonator for the SX in lieu of the 50MHZ. SX wouldn't run properly. It ran, but not "right".
Then here is the *really* strange thing -- I put a DIFFERENT 50MHZ resonator in (a blue murata from the same Parallax-sold batch as the original 50MHZ resonator), just for sh*** and grins. Guess what? PERFECT. No serial dropouts, host gets every byte fine, and the servo behaviors are truly wonderful.
So this led me back to the SX manual. For both the 50MHZ and 20MHZ trials I used OSCHS2. My understanding had been that the lower the setting you can get away with, the less power?
Then I looked over some of JonnyMac's recent columns and he uses OSCHS3 for 50MHZ and OSCXT2 for 20MHZ?
How is one to know? Are the "brittle" resonators (like the blue muratas) "high-speed" and the "mylar-y" resonators (like the brown 20mhz) "normal" speed?
If there is a cogent explanation of the fine points in choosing the clock setting, do tell.
I may have other problems going on here, of course, but given that a swap in resonators of the same type gave such different results, I figured I'd nail that down first.
Code & circuit for my SX controller board are here: http://forums.parallax.com/showthread.php?p=703230
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Now, I spent all morning get SERIN failures (sporadically) on the host side when it would query the SX. At all baud rates. Board worked perfectly on the bench.
After much trial and error, I discovered that when the motors were OFF that everything would be fine. Motors ON = serial problems. I figured maybe it was noise, but it seemed weird because the PSC (at same baud rates, exact same wiring, power supply, etc) was fine for the nearly 18 months it was installed.
In any case, it seemed like noise would be the culprit, and a single battery supplies all power systems, but I couldn't find anything amiss on the serial line with a scope, no brownouts, etc.
I decided to try a 20MHZ resonator for the SX in lieu of the 50MHZ. SX wouldn't run properly. It ran, but not "right".
Then here is the *really* strange thing -- I put a DIFFERENT 50MHZ resonator in (a blue murata from the same Parallax-sold batch as the original 50MHZ resonator), just for sh*** and grins. Guess what? PERFECT. No serial dropouts, host gets every byte fine, and the servo behaviors are truly wonderful.
So this led me back to the SX manual. For both the 50MHZ and 20MHZ trials I used OSCHS2. My understanding had been that the lower the setting you can get away with, the less power?
Then I looked over some of JonnyMac's recent columns and he uses OSCHS3 for 50MHZ and OSCXT2 for 20MHZ?
How is one to know? Are the "brittle" resonators (like the blue muratas) "high-speed" and the "mylar-y" resonators (like the brown 20mhz) "normal" speed?
If there is a cogent explanation of the fine points in choosing the clock setting, do tell.
I may have other problems going on here, of course, but given that a swap in resonators of the same type gave such different results, I figured I'd nail that down first.
Code & circuit for my SX controller board are here: http://forums.parallax.com/showthread.php?p=703230
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Comments
FYI: I've been using OSCXT2 with the 20Mhz resonators.
Robert
1.
I tested some more this afternoon, and I'm sure I'm getting noise on the serial line. I swapped resonators again, but this time left all serial cables disconnected, and I get noise. I realized during earlier test I still had Stamp serial cable and SX-Key connected (the SX was not running from the key; I just left it in so I could hit program again when I wanted).
I think that whatever noise suppression is on-board the SX-Key brings the noise on my controller board down just enough that it doesn't error. With Key and Stamp serial disconnected it's sporadic.
I've got a 4.7k pull-up on the SX serial pin (open true) -- before pulling the board to work on noise suppression, I decideed to try enabling the pullup on that pin (to give a little more noise immunity on top of the external pull-up). Y'know what, it *really* helped.
On the firmware end I cut the time delay for the "host to get ready" before TXing of a byte to 1ms from 5ms and that helped a lot too (my BSP has yet to choke on the shorter turnaround time). I think the longer delay let a greater chance of noise creep in (mostly in the form of bogus stop bits).
If anyone cares to check out my photo of the board against the schematic -- there's a cap on the SX, and the 5v power supply for the 'bot is heavily filtered and the power is clean. And the PSC worked fine, so it's most likely my board -- since that's the only thing that changed
My best guess is that I cheated a bit and ran the Vss wire to the resonator center pin to right near the Vss host header pin. That pin however, remains disconnected; the board receives Vss from the servo power supply V- -- this was to avoid a ground loop on the single batter setup. I'm thinking I should have tied the center pin of the resonator right to the Vss pin of the SX, which puts it next to the .1uf bypass cap?
2.
OK, OSCXT2 for 20mhz. I still couldn't get the SX running right, but I'm going to check that out separately with simpler code (not sure my firmware can handle 20mhz -- it's borderline).
That still doesn't answer the question of how do you know which to use, when????? Outside of JonnyMac's and other professionals' sample code and the rather broad frequency ranges specified in the SX Manual.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
From my experience you need to experiment to find the right setting. But for a particular resonator the setting should be the same.
I use the lowest setting that works. Higher settings use more current and can stress the resonator.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
There is no general rule which OSC setting to use because it depends on the type of the external resonator/xtal connected to OSC1/OSC2. Some components come with internal capacitors (like the "blue" Murata resonators available from Parallax), others require external capacitors, parallel resistors, etc.
As a rule of thumb, you can say, the higher the clock frequency, the higher the gain setting should be. But as Bean mentioned, sometimes, it requires a bit of experimenting to find the right setting for a particular resonator/xtal. It is correct: Higher gains result in more supply current, and also cause some more EMI.
Finding the lowest setting that works for a clock device is fine, but you should consider the possible ambient temperature range. When you minimize the gain, it can happen that the oscillator will not start at lower temperatures.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
IFBD -- do you disable the internal feedback resistor when, say, using an external 10k resistor across the OSC pins along with a 20-50MHZ resonator w/internal caps? Or is that just for the internal RC oscillator? or?
I've not yet seen that directive show up in code I've sampled, so I never thought about until I checked out the OSC settings table in the SX manual more closely.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Since everything is brads, it's easy to do some nice algorithmic work on obstacle distances and angles -- esp. for things like pan angles -- looking front, side, etc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
In fact my experience shows that too high a setting can cause some resonators even at 50 MHz to not work.
Cheers,
Peter (pjv)
OSCXT2 or OSCHS1 ?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my
www.mercedes.com.my
OscHS3 is the highest;
OscHS2
OscHS1
OscXT2
OscXT1
etc
Cheers,
Peter (pjv)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my
www.mercedes.com.my
When I was having my debug at 3 volt problems two days ago I spent a bunch of time on these issues, and, among other things, I did exactly what you are saying. I happen to have a scope that can go to 500MHz, and a special 1.5 pF low capacitance probe good to 1 GHz to go with that, so I'm pretty sure my measurements were real.
The debugger defaults the oscillator setting to OSCHS1, regardless of the setting in your source code. In debug mode, you can only override that by changing the setting in the DEVICE panel, and then programming the chip via that avenue. The SXKey delivers an amplitude to the oscillator input pin -OSC1- pretty consistent, regardless of frequency, but the output observed on the oscillator output pin -OSC2- varied dramatically with the oscillator gain settings, from next to nothing to hitting the rails.
Guenther advises that in debug that is of no consequence..... I suspect therefore that during debug the chip uses the input pin of the oscillator, whereas while not in debug it would of course use the output pin, or some buffer close to there. I still think my debug problems were related to the gain settings, but hey, I'm runnin' right now, and I'll dig deeper some other time.
In one of my 3 volt scenarios (SX48) the oscillator will not run with a 50 MHz resonator and a gain setting of OSCHS3. I need to back it off to HS2.
So my take on all this is along the lines as Terry stated; crank it up till it quits working, and then back it off one notch. That is if you can afford the extra current, and if you can't, then I would crank it down until it quits , and then up it by a notch. And if the span is wide, then park it near the middle. But do keep operating temperatures and different voltages in mind.
Cheers,
Peter (pjv)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php