Connect with us

Newbie Arduino questions

Discussion in 'Microcontrollers, Programming and IoT' started by JFS-Chatt, Feb 16, 2015.

Scroll to continue with content
  1. JFS-Chatt


    Jan 7, 2015
    Hi all,

    I have read, read, and read some more about microcontrollers in general. I was feeling pretty comfortable about beginning with an Arduino Uno but now I am feeling thoroughly confused about how bits relate to the physical processor itself.

    First, do the number of bits correspond to the number of output pins? Let's say we have an 8-bit order to produce 256 different states, the chip puts each of the pins either ON or OFF. Each individual output pin can only be on or off. Is this correct?

    Secondly, is the purpose for the PWM outputs to have a single pin capable of producing 256 different outputs (depending upon the duty cycle)?

    Thanks in advance.
  2. Bluejets


    Oct 5, 2014
    The assumption with many micro instructions/tutorials is you have some electronics knowledge.
    It would be impossible to give complete tutorials on everthing leading up to micros as one would never get on to the subject.
    If you find something such as the description of "8 bit" you do not understand, the normal process is to read about that.
    Same goes for PWM.

    For 8 bit do a search for binary code.(wiki)

    For PWM .....
  3. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    Nov 28, 2011
    You can disregard that unhelpful post from Bluejets. Bluejets, it's not necessary to try to answer every post - only answering the ones you know about is fine!

    The "number of bits" tells you something about the complexity and processing power of the processor core. It is the native "word size" of the device, i.e. the width of the binary numbers that it is designed to process naturally and efficiently. Small micros are typically 8-bit. The CPU in your PC is 32-bit or 64-bit.

    Eight-bit micros normally have I/O ports that are eight bits wide as well, for convenience. Sometimes, one or more ports are not fully brought out to the device's pins. This will happen if the number of pins available for I/O is not an exact multiple of the port width; at least one of the ports may be only partly implemented.

    If an 8-bit port is fully implemented in the device and brought out to eight I/O pins, and if all of those pins are "set to output mode", i.e. they are all under control of the micro, then the micro can produce 256 different combinations of output values. Each line can be either high or low, i.e. one of two states. 28 is 256.

    Often though, port pins are used for discrete individual control signals, so one pin might control part of one circuit, two more pins might control part of a different circuit, and so on. In those cases it's not useful to point out that there are 256 possible output state combinations.

    Also, ports are used for both input (allowing the firmware to detect the state of parts of the circuit) and output (allowing the firmware to control parts of the circuit), and often, ports are split between those functions. For example a port may be used as five inputs and three outputs. It depends on the requirements of the system and the capabilities of the port pins.

    Certain port pins also have dual functions with built-in peripherals, such as ADCs, timers, PWM generators, etc. For each pin, firmware decides whether the pin will be used as general purpose I/O (GPIO), i.e. a simple digital input or output through a port, or whether it will be used for a special function, such as an analogue input, a clock input, a PWM output, or whatever.

    PWM uses a single digital output pin to produce an analogue signal. The pin is only ever either high or low - it is a standard digital output pin - but it alternates between high and low at a fairly high frequency, called the PWM frequency. The duty cycle of the PWM pin varies according to a value programed into the PWM generator inside the device, and the signal from the pin is passed through some simple analogue filtering (just a resistor in series, then a capacitor to ground, sometimes repeated) to "smooth out" the PWM frequency and give a voltage that corresponds to the duty cycle of the signal.

    This analogue signal can then be used to control the circuitry. PWM is a cheap and relatively low-performance way to provide a crude analogue output from a device whose pins are only capable of digital output.

    A bit of Googling will tell you all about how PWM works, and check out that last link in Bluejets's post.
    Last edited: Feb 17, 2015
    BobK and hevans1944 like this.
  4. JFS-Chatt


    Jan 7, 2015
    Thank you much! I definitely had some misunderstandings and I spent a good part of today reading about PWM. So far it is more intuitive than some of the other topics I've tried.

    This helps me make better sense of some things I've been reading about bit resolution, too.
  5. hevans1944

    hevans1944 Hop - AC8NS

    Jun 21, 2012
    I don't want to overwhelm you with details. As per usual, @KrisBlueNZ provided you with a nice overview of microprocessors in general.

    I think you should buy an Arduino Uno R3, a solderless breadboard, a couple dozen (or more) color-coded jumper wires to connect between the Arduino Uno and the breadboad. You will also need a variety of components to play with. Here is a link to a pretty good tutorial along with some nice pictures. You don't need ALL the stuff mentioned there, but a handful of LEDs and a variety bag of resistors in 1/4 watt or 1/2 watt persuasion will get you started. You can buy more "goodies" later as you gain experience programming the Arduino Uno.

    I received an Arduino Uno R3 with a plastic holding tray and a half-sized solderless breadboard (identical to the one shown in the picture at the link above) as a Christmas present two years ago. Today, I finally found my "round tuit" and downloaded the Windows development environment (it's free!). Within just a few minutes I was able to modify the "Blink" example program, re-name it to "My_Blink" and upload the modified program to the Arduino Uno. It worked! Hello, World, here comes Hop!

    Only problem was I had to use the Windows Device Manager to see which COM port it assigned to the USB driver. The default in the development environment is COM3 and my PC chose COM5 (probably because I had used other USB drivers in the past). The program downloaded as a 93.5 MB .exe file to a Windows 7 Pro running on an older HP laptop. I let the .exe file run in administrative mode, including allowing Windows to intall the USB driver. You can also create your own Arduino directory and download a .zip file instead of the .exe file. All the software is available for free download from the Arduino web site.

    So, jump in, get your feet wet and enjoy learning how to use the Arduino Uno. If a 70+ year old codger can do it, so can you! There is a HUGE user community out there and lots a free code (applications) to download and adapt to your particular needs. Oh, and for some reason I haven't been able to determine, Arduino code is called a "sketch" instead of a program. Maybe because it has to be interpreted by a compiler/linker/loader before it can be uploaded to the Arduino Uno. I don't care about that... it could be Keebler Elves doing all the work behind the scenes for all I know.

    If you want to know about the internals of the Arduino Uno, download the 660 page PDF datasheet from Atmel. We warned, it is a bit overwhelming for even experienced electronic hobby users. But it is probably the only way to extract the full capabilities of this fine little processor.

    73 de AC8NS
    Last edited: Feb 17, 2015
    KrisBlueNZ likes this.
  6. Jouellet


    Feb 2, 2015
    If you are new with Arduino, my only advise: go on Youtube and look for Jeremy Blum's tutorials

    Very well made, and easy to understand !

    The kid is a genius !
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day