Author Topic: Starting with microcontrollers  (Read 14821 times)

0 Members and 1 Guest are viewing this topic.

Offline eneuro

  • Super Contributor
  • ***
  • Posts: 1562
  • Country: 00
Re: Starting with microcontrollers
« Reply #25 on: July 01, 2014, 01:34:50 am »
avr:  atmega, attiny etc - cheaper programmer, more expensive chips

Even this AVR ATTiny85 could do this job, with fast PWM on PB1 for power control or use PB1,PB0 for software I2C ;)

It has 4 ADCs, but to use ADC0 on RESET pin High Voltage programmer may be needed for development if program reflash needed in the case of bugs.
However, it is possible write its 8KB flash (512 bytes SRAM) using... old laptop with LPT port and a few resistors  in AvrDude DAPA mode, using text editor to write C source code and compile under Linux of course >:D
AVR Microcontrollers in Linux HOWTO
Sometimes such simple tools have advantage-you know exactly what optimisations are made and what is passed to the compiler if you can do it in a few shell commands or from makefile.
Just finishing another project and pushed next ATTiny85 to the limits, but its 2 timers in fast PWM mode work as expected, so another DIP8 monster switched to internal 8 MHz clock is ready to go  8)
12oV4dWZCAia7vXBzQzBF9wAt1U3JWZkpk
“Let the future tell the truth, and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I have really worked, is mine”  - Nikola Tesla
-||-|-
 

Offline akisTopic starter

  • Frequent Contributor
  • **
  • Posts: 981
  • Country: gb
Re: Starting with microcontrollers
« Reply #26 on: July 01, 2014, 08:59:23 pm »
My simulator supports the PIC16F84 complete with assembler, C compiler, debugger and sample sims. So I decided to start looking at the PIC16F84 first. I downloaded the reference manual and I must admit with over 30 years professional experience starting with Z80, 68000, 80386 - I am finding this manual the most stupidly and badly written piece of trash. Which must say a lot about the company behind it.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Starting with microcontrollers
« Reply #27 on: July 01, 2014, 10:54:56 pm »
Quote
I am finding this manual the most stupidly and badly written piece of trash.

I think consensus seems to be that Microchip and Atmel both make fairly good datasheets.

Quote
Which must say a lot about the company behind it.

Or the folks making that statement.

Or both.

================================
https://dannyelectronics.wordpress.com/
 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5183
  • Country: ro
  • .
Re: Starting with microcontrollers
« Reply #28 on: July 01, 2014, 10:57:55 pm »
What do you mean by "reference manual", the datasheet or something else?

I actually found the datasheet quite easy to understand, but I wasn't "damaged" by older architectures.

// ps. The PIC16F84 is ancient. You really should look into something more modern.
« Last Edit: July 01, 2014, 11:01:03 pm by mariush »
 

Offline boz

  • Regular Contributor
  • *
  • Posts: 79
  • Country: nz
    • Roving Dynamics Ltd
Re: Starting with microcontrollers
« Reply #29 on: July 01, 2014, 11:50:58 pm »
I'm the biggest Microchip Fanboy there is but seriously just get a base Arduino UNO

1. The IDE is a bit simple and crappy but it works out of the box and its also real "C" your programming in just like the big boys
2. There is a big community geared to newbies while you learn. (no ones going to jump on you if you ask a dumb question)
3. Its cheap (about $15 for a UNO clone)

Dont bother with anything more complicated yet such as an arduino mega, nanos or PIC ARM 'duino clones or you just end up with frustration due to 3.3V vs 5V or other silly issues, once you have got the basics you can move on to bigger/better AVR's PIC's, 430's or ARMS.
Fearless diver and computer genius
 

Offline akisTopic starter

  • Frequent Contributor
  • **
  • Posts: 981
  • Country: gb
Re: Starting with microcontrollers
« Reply #30 on: July 02, 2014, 12:01:49 am »
What do you mean by "reference manual", the datasheet or something else?

I actually found the datasheet quite easy to understand, but I wasn't "damaged" by older architectures.

// ps. The PIC16F84 is ancient. You really should look into something more modern.

No,  I am talking about the manual and the way it's thrown together, not the architecture which I can not express an opinion on as I have not seen enough of them.

I am reading now the Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet.pdf and it's so much better (the document, not the architecture).

 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: Starting with microcontrollers
« Reply #31 on: July 02, 2014, 06:34:44 am »
I'm the biggest Microchip Fanboy there is but seriously just get a base Arduino UNO

1. The IDE is a bit simple and crappy but it works out of the box and its also real "C" your programming in just like the big boys
2. There is a big community geared to newbies while you learn. (no ones going to jump on you if you ask a dumb question)
3. Its cheap (about $15 for a UNO clone)

Dont bother with anything more complicated yet such as an arduino mega, nanos or PIC ARM 'duino clones or you just end up with frustration due to 3.3V vs 5V or other silly issues, once you have got the basics you can move on to bigger/better AVR's PIC's, 430's or ARMS.
+1 to this thought. And if you wish to improve on 1. above, there is a solution: grab the free Atmel Studio 6.2 and install the free Arduino extension from Visual Micro (available directly from inside AS 6.2 in the Tools/Extension Manager dialog). That links the AS 6.2 to Arduino IDe and then you can write you code in a "proper" IDE which is miles ahead of the original Arduino environment.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline 22swg

  • Frequent Contributor
  • **
  • Posts: 274
  • Country: gb
Re: Starting with microcontrollers
« Reply #32 on: July 02, 2014, 08:34:08 am »
Akis   You seem to be starting from a strange angle, what is your purpose ?, learning about mcu from a software aspect  , for a particular hw project  or just to get up to date. you mention sim , this will help with finding bugs, but will not take the place of actual hardware, you can sim  turning on a LED , but that's not to say it will actuall be ON .   I also came from Z80 to 16F84 and you can do loads with it but not what you had in your list ?  the "Manual" data sheet is basically a list of registers and how to set them up and use them , no more .  I learned from code examples for asm and C

Looks like some good advice posted below ....
 
boz, I am the biggest MC fan :)
Check your tongue, your belly and your lust. Better to enjoy someone else’s madness.
 

Offline akisTopic starter

  • Frequent Contributor
  • **
  • Posts: 981
  • Country: gb
Re: Starting with microcontrollers
« Reply #33 on: July 02, 2014, 10:11:25 am »
After I decided to look into MCUs I discovered that my real-time, interactive simulator supports the PIC16F84A, complete with assembler/C compiler, real time debugging etc. Since I have to start from somewhere I thought it would be a great idea to go with what my simulator already provides, including samples, assembly files, ROM files, configuration files etc. I also downloaded MPLAB X but the simulator is so much better for just starting on a basic circuit, modifying the assembly file, running again etc

After a while I needed the PIC16F84 reference manual to understand what the assembly was doing but I did not like it (hence my comments), so I gave up on it.

As per your suggestions I started looking at the ATMEL tinyAVR ATiny25/45/85 which has a very nice datasheet (should be called reference manual but anyway).

Once I am more familiar with MCUs my first project is to monitor 4 temperature sensors and then nudge up or nudge down the power of an amplifier. Because there is a lot of lag between changing the power and sensing some temperature change, it may even be an inverse correlation for a while, in other words, you sense the temperature is too high, you lower the power, and the next X readings are even higher. So unlike a current limit implementation where we adjust the current to stay below a level, and the feedback is instant, with temperature sensing the feedback is very very slow. If I employ an analogue solution, similar to current limiting, as soon as the temperature exceeds a threshold, the analogue system would switch the power off completely, because it will not be getting a quick feedback. So the device will be working in a "full power on" - "power totally off" cycle, which may succeed in keeping the temperature below a threshold, but is not what I want. So I thought an MCU would cope with this much better.

As an example:

1) get temperature reading
2) if temperature greater than X, decrease power by 10%
3) if temperature lower than Y, increase power by 10%
4) wait 10 seconds

That simple algorithm may produce better results than I can do in pure analogue, although I am sure it can be done in analogue with clever circuitry.
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 28702
  • Country: nl
    • NCT Developments
Re: Starting with microcontrollers
« Reply #34 on: July 02, 2014, 10:18:23 am »
This sounds like implementing a (PID) control loop. It may take some math to get that working properly though. May I suggest the book 'Applied control theory for embedded systems' by Tim Wescott?

OTOH with some understanding of control theory this problem can be tackled by analog circuitry as well.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline akisTopic starter

  • Frequent Contributor
  • **
  • Posts: 981
  • Country: gb
Re: Starting with microcontrollers
« Reply #35 on: July 02, 2014, 10:47:12 am »
Maybe there is a simple and completely analogue solution. I have experimented with adding RC delays to forbid the circuit from going fully on or fully off, but with little success. Here is the thread I have just posted, more knowledgeable people than me might have solutions.

https://www.eevblog.com/forum/projects/control-system-with-feedback-time-delay/
 

Offline Monkeh

  • Super Contributor
  • ***
  • Posts: 8199
  • Country: gb
Re: Starting with microcontrollers
« Reply #36 on: July 02, 2014, 10:49:54 am »
I am reading now the Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet.pdf and it's so much better (the document, not the architecture).

Take a look at the MSP430 documentation.

www.ti.com/lit/ug/slau144j/slau144j.pdf
www.ti.com/lit/ds/symlink/msp430g2553.pdf
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 28702
  • Country: nl
    • NCT Developments
Re: Starting with microcontrollers
« Reply #37 on: July 02, 2014, 10:57:06 am »
Maybe there is a simple and completely analogue solution. I have experimented with adding RC delays to forbid the circuit from going fully on or fully off, but with little success. Here is the thread I have just posted, more knowledgeable people than me might have solutions.

https://www.eevblog.com/forum/projects/control-system-with-feedback-time-delay/
For this problem you need to understand/use control theory otherwise you are not going to crack it. Because of the huge lag between adding heat and sensing it you probably need some feed-forward compensation as well. If you know the thermal capacitance of what you are heating you can make an estimate on the temperature based on the amount of energy you put into the 'system'.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Starting with microcontrollers
« Reply #38 on: July 02, 2014, 10:57:49 am »
Quote
So I thought an MCU would cope with this much better.

What you want is a PID loop, which can be done either digitally (via an mcu for example) or analogly - tons of examples there as well.

If you do it digitally, it can be implemented with either full-on/full-off, or via pwm. Either way, not much of a difference.
================================
https://dannyelectronics.wordpress.com/
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf