uController for Amp

What people are working on at the moment
User avatar
izzy wizzy
Old Hand
Posts: 1496
Joined: Fri Nov 02, 2007 7:02 pm
Location: Auckland NZ
Contact:

#16 Re: uController for Amp

Post by izzy wizzy »

I've found a company local to me that stocks the arduino stuff I'm after. I'm a bit conflicted as I like the raw nature of the avr approach but the unknowns, albeit small maybe, could lead me to the arduino with the higher likelihood of success.

The arduino Uno is very cheap with oodles of i/o and they also have a 16x2 display available.
User avatar
ed
retired
Posts: 5384
Joined: Thu Jun 21, 2007 4:01 pm
Location: yorkshire
Contact:

#17 Re: uController for Amp

Post by ed »

I'm not sure what the issue is but maybe I'm missing something here....

You don't need a programmer for the arduino stuff, you just plug the arduino into the usb on the computer. The arduino ide does it all. I've used all the arduino versions and can't fault any one one of them, uno, nano, mega. I can't criticise any of them for what they do. The only problem I've ever found is the Chinese sourced nanos sometimes have a dodgy(old) bootloader and the watchdog timer doesn't work.

On uk ebay you can still find a nano or uno for less than £5 and the ide is free
the ssd1306 are about £3.50
an st7735 is about £7.50

edit: I beleive there is an i2c plug in for the 16x2 lcd units which means you only need 3 pins but I can't vouch for it as I've never used it.
If you really want to go 'raw nature' then my previous post explains writing the program in the arduino ide and then uploading the hex code to an avr chip with studio 7, but you'll need one of these programmers...2 for £8:
https://tinyurl.com/j3d7n3fu
not sure why anybody would need 2. this method allows use of all the arduino libraries for peripherals, which are hard found for studio 7.
There's nowhere you can be that isn't where you're meant to be
User avatar
izzy wizzy
Old Hand
Posts: 1496
Joined: Fri Nov 02, 2007 7:02 pm
Location: Auckland NZ
Contact:

#18 Re: uController for Amp

Post by izzy wizzy »

ed wrote: Sun Sep 12, 2021 8:14 am I'm not sure what the issue is but maybe I'm missing something here....

You don't need a programmer for the arduino stuff, you just plug the arduino into the usb on the computer. The arduino ide does it all. I've used all the arduino versions and can't fault any one one of them, uno, nano, mega. I can't criticise any of them for what they do. The only problem I've ever found is the Chinese sourced nanos sometimes have a dodgy(old) bootloader and the watchdog timer doesn't work.

On uk ebay you can still find a nano or uno for less than £5 and the ide is free
the ssd1306 are about £3.50
an st7735 is about £7.50

edit: I beleive there is an i2c plug in for the 16x2 lcd units which means you only need 3 pins but I can't vouch for it as I've never used it.
The bit that you might have missed was I was struggling to find a very general programmer for the AVR chips. I know the Arduino stuff just pops on the USB.

Anyhoo, I've spent today immersed in Arduino and that's where I'm going now so good to know your positive experience.

Something that might be obvious but not to me is two of my inputs are the bias off the finals. No signal no AC but if there's signal, there will be AC on the DC. Do the inputs ignore the AC element? Or do I have to condition it to remove the AC element?

So far the Uno looks good and I've found a 16x2 display with I2C for no more money than one without.
User avatar
ed
retired
Posts: 5384
Joined: Thu Jun 21, 2007 4:01 pm
Location: yorkshire
Contact:

#19 Re: uController for Amp

Post by ed »

posts overlapped
my previous post has examples of programmers
Something that might be obvious but not to me is two of my inputs are the bias off the finals. No signal no AC but if there's signal, there will be AC on the DC. Do the inputs ignore the AC element? Or do I have to condition it to remove the AC element?
good point...I only biased the sv572 when there was no signal
There's nowhere you can be that isn't where you're meant to be
User avatar
Nick
Site Admin
Posts: 15705
Joined: Sun May 06, 2007 10:20 am
Location: West Yorkshire

#20 Re: uController for Amp

Post by Nick »

The ADC will measure the signal it's presented. If you want to remove AC then it either needs to be done before the input or in the processor or both.
Whenever an honest man discovers that he's mistaken, he will either cease to be mistaken or he will cease to be honest.
User avatar
izzy wizzy
Old Hand
Posts: 1496
Joined: Fri Nov 02, 2007 7:02 pm
Location: Auckland NZ
Contact:

#21 Re: uController for Amp

Post by izzy wizzy »

All good points. At the moment, I should try and keep this simple. The temptation with this is to make use of the capability but then that will probably take it beyond mine.
User avatar
izzy wizzy
Old Hand
Posts: 1496
Joined: Fri Nov 02, 2007 7:02 pm
Location: Auckland NZ
Contact:

#22 Re: uController for Amp

Post by izzy wizzy »

In looking at the hour meter function for valve life, I've seen a bunch of different options. Some have involved nothing more than counting some stuff and bunging a value in EEPROM. However continual writing to a single space might wear it out as I understand they have a life. Was thinking store accumulating value in RAM and then write to EEPROM just before turn off.

Then I've seen a more sophisticated example where an RTC module is added with battery attached so the timimg is kinda done for you and then I think a value can be stored on that module and kept alive by the battery (possibly - not 100% sureon that yet). Another example used an SD card add on to store the hours accumulated.

I have a questions of course. Is the EEPROM life thing something of concern? If so, I should look at how many writes this thing could do in it's lifetime of use and make a call.

Is the RTC a bit of overkill?

Likewise SD card storage for one variable could be overkill.
User avatar
Nick
Site Admin
Posts: 15705
Joined: Sun May 06, 2007 10:20 am
Location: West Yorkshire

#23 Re: uController for Amp

Post by Nick »

They have a write spec of 100000 writes. So that's 10 years at a write per hour. You can also extend this by using more of the 256 bytes available. Trying to write eeprom at a brownout interrupt is not likely to work.
Whenever an honest man discovers that he's mistaken, he will either cease to be mistaken or he will cease to be honest.
User avatar
izzy wizzy
Old Hand
Posts: 1496
Joined: Fri Nov 02, 2007 7:02 pm
Location: Auckland NZ
Contact:

#24 Re: uController for Amp

Post by izzy wizzy »

Thanks Nick. That makes things easy to use EEPROM. Hadn't planned to do writes in a brownout situation just the thing to do before turn off or at that life, just update once an hour anyway as the way I use the amps, the EEPROM will outlast me.

The RTC module might just make things super easy if code/timers aren't that accurate but they might be good enough.
User avatar
jack
Thermionic Monk Status
Posts: 5493
Joined: Wed Dec 29, 2010 8:58 pm
Location: ɐılɐɹʇsnɐ oʇ ƃuıʌoɯ ƃuıɹǝpısuoɔ
Contact:

#25 Re: uController for Amp

Post by jack »

The internal timers are likely to be easily good enough for something like an hours counter for a tube - there is no reason why that has to be particularly precise.

If accuracy is a concern, use an external crystal, either in a chip (so just one extra component) or discrete (so just the crystal and two small caps). Generally the external crystal is some high multiple of 60 Hz, e.g. 16MHz and is used as the main clock for the uP. You then set up a 1 second internal counter and just count hours that way in an interrupt service routine (ISR) setting a global variable to the number of hours (32 bit number).

It's generally a bad plan to do anything lengthy in an ISR as doing so blocks any other possibly time-critical code from running, i.e. bad practice. Writing to eeprom falls into this category.

In your main (non ISR) code, which is normally a continuously running (non blocking) loop, check the hours value. If its value has changed from last time you went round the loop, you know a new hour has ticked over, so you can write the new hours run values to eeprom.

Doing a write only for completed hours means that on average you will lose 30 minutes of unrecorded time (average partial hours) each time you use the amp. You may want to record the number of times the amp has been turned on since a tube was installed, divide that by two and add it to the stored saved hours to give a more accurate result when displaying the hours for a tube.

You can do this easily by simply recording an incremental on-count for the amp as a whole and for each tube. Do this before entering the main program loop in your code as it's a once-only operation at power on.

When a tube is replaced, set the tube's own on-count and hours count to zero.

Every completed hour, just increment each tube's hour count.

When displaying hours, display the tube's hour count + (tube's on-count / 2). Over time, this will become progressively more accurate.

I would also strongly suggest calculating and storing a checksum byte in the eeprom periodically, possibly after finishing the hourly updated for each tube.

This value can then be checked at power-on to see if your data is valid.
Vivitur ingenio, caetera mortis erunt
User avatar
Nick
Site Admin
Posts: 15705
Joined: Sun May 06, 2007 10:20 am
Location: West Yorkshire

#26 Re: uController for Amp

Post by Nick »

I think Jacks algorithm should be fine, though I wonder if it will fail to be correct with repeated less than a half hour use. You can trim the internal clock to get closer to xtal accuracy without the extra parts, depends on the accuracy you need.

Yep, writing to the eeprom when performing an orderly shutdown is fine, the programmer in me was thinking about power failure situations where it would be lost, every hourly and at turn off would get you close assuming not many power failures.

The checksum is good, but if you are going to do that, maybe write the data + checksum to two places so you have a chance that only one is corrupt, so you can recover.

But the most important thing I can say about the AVR chip is don't use the first (zero) byte in the EEPROM unless you have too and then only if you have external reset control. The things have a habit of trashing the first element of the eeprom on an uncontrolled power down.
Whenever an honest man discovers that he's mistaken, he will either cease to be mistaken or he will cease to be honest.
User avatar
jack
Thermionic Monk Status
Posts: 5493
Joined: Wed Dec 29, 2010 8:58 pm
Location: ɐılɐɹʇsnɐ oʇ ƃuıʌoɯ ƃuıɹǝpısuoɔ
Contact:

#27 Re: uController for Amp

Post by jack »

There's an even simpler way...
  • Every time you turn on the amp, add one to the "on count for the amp", AOn
  • Every hour the amp is on, add one to the "hours on for the amp", AH
  • Every time you insert a new valve, just record the amp's on-count, VnOnInit = AOn, and hour-count for that tube, VnHInit = AH (where "n" is a digit identifying that valve)
  • Initially (first use), AOn, AH, VnOnInit & VnHinit (for each "n") are all zero
Then...
  • When reporting an hour count for valve "n", just report "Times on" = (AOn-VnOnInit) + 1 and "Hours on" = (AH-VnHInit)+((AOn-VOnInit)/2)
Doing it this way means that each hour you are just updating one field in the EEPROM instead of updating data for each valve.
Vivitur ingenio, caetera mortis erunt
User avatar
izzy wizzy
Old Hand
Posts: 1496
Joined: Fri Nov 02, 2007 7:02 pm
Location: Auckland NZ
Contact:

#28 Re: uController for Amp

Post by izzy wizzy »

Thanks for the tips. Not having coded anything for quite a while, I'll have to have a think about what you both are saying to let the logic of it sink in. The most important aspect is monitoring the presence of bias supply there or not with maybe an over current monitor as well.

So far I'm trying to assemble the hardware based on what functions I want it to achieve.

Edit: There is a part of me that thinks the easy way out is the RTC module not so much for accuracy but ease. It starts when turn on or log start time and read time at turn off. A bit of logging of time along the way even. It might be considered cheating.
User avatar
Nick
Site Admin
Posts: 15705
Joined: Sun May 06, 2007 10:20 am
Location: West Yorkshire

#29 Re: uController for Amp

Post by Nick »

You will probbably need more code to talk to the RTC than to count hours using a local timer.

If you are happy to ignore power fail conditions I would count seconds and store a seconds used time for each valve and just update it when the amp off button is pressed. That gives you 100000 listening sessions before you worry about the eeprom.

But I would think more how to check the bias is there and the cathode current. Both will need some conditioning to get to 0-5v range for the ADC and protecting the micro from valve failure conditions.
Whenever an honest man discovers that he's mistaken, he will either cease to be mistaken or he will cease to be honest.
User avatar
izzy wizzy
Old Hand
Posts: 1496
Joined: Fri Nov 02, 2007 7:02 pm
Location: Auckland NZ
Contact:

#30 Re: uController for Amp

Post by izzy wizzy »

You've highlighted the two things I've been spending my time on. Just how much conditioning do I need so been trying out ideas in ltspice. Hadn't fully considered all fault conditions yet.

If timers can just go about their business while the uC is monitoring then great. This is where my ignorance of the architecture and my programming rustiness is kicking in.

Hopefully once I get to try these things out, it'll come back to me.
Post Reply