Tuesday, June 2, 2015

A outline of what's in the test.

The test will be in our normal classroom on Wednesday 10th June at 10:14am

There will be a picture of an Arduino like this below and you'll annotate it with text and arrows. You may be asked to identify a crystal, capacitor, resistor, LED or voltage regulator too.




There will be one of the two pages from the Atmel mega 328 family's data pdf. You'll be required to comment on some of the functions in the page below and most of the features in the very front page.







There will be questions about a schematic involving the Arduino like the one below.


There's a clearer copy of this in a pdf on our Moodle page.



Test Information

There will be a theory test on Thursday 10 June. It will be closed book and you must complete it in 1 hour and 45 minutes. We will discuss some of the items in the test on the previous class.

There will be a question on the main parts of the Arduino. See the labelled diagram above. This is not exactly the same as our Arduino but, apart from the DIL processor and colour, is pretty close.

There will be a question on the page above called The Front Page of the Mega328. You will be expected to write a sentence explaining some of the features listed. 

There will be questions on the functions diagram of the Mega328. You will be given a copy of this diagram and be expected to write a short paragraph on up to three blocks.

There will be a question about the Arduino schematic diagram above or similar.

Also there's buggy program. A program will be given to you with errors in it. You will have to identify the errors. Mostly syntax violations.

A problem to do with sampling real world inputs will be given and you will be asked how you would respond to this using the Arduino.

You will be asked to write a simple assembly language program. You will be asked to write a program in Arduino C.

There may be other questions but only on items we have studied in class including serial buses, pin outs of the Arduino and the mega328p, voltage dividers, the stack and interrupts.

Please contact me about any problems. Good luck.

PeterB





Sunday, May 24, 2015

Pulse width modulation

Good simulation vid

The Arduino page on analogWrite() here

You can use pwm to control higher voltages like here.





i2c Bus

Most popular of the serial buses. Uses one wire for clock and one wire for bidirectional data. Based on Phillips' iic network. Lots of chips use the i2c protocol.

Good short introduction here. Not Arduino based.

Using i2c to connect arduino to eeprom chip that holds 256k bits, here.



Interesting use of i2c OLED display.

SPI or i2c. Which one is ""better"?

Wednesday, May 13, 2015

The SPI bus

Fastest of the serial I/O on the Arduino.

A good tutorial on spi using a digital potentiometer chip here

A tutorial on the spi bus, more technical here

Two Arduino's connected via spi here. Code via link to github.





Tuesday, May 12, 2015

Using hex files from AVR studio to program Arduino

Programs needed are just AVR Studio and avrdude. I used AVR Studio version 4.14 and the avrdude that came with the Arduino suite.

Step 1. Write your program in assembler in AVR Studio, build then save the hex file.
Step 2. Go into the command prompt and invoke avrdude with the right switches.

I started with the usual Arduino C blink program, just to make sure I got the COM port right and to see the hardware was all working. Then did steps above.

Below are some relevant screen shots.




Blink for AVR Studio 4 assembler


.include "m328pdef.inc"


;Based on http://www.robertoinzerillo.com/wordpress/?p=5
;-----------------------------------------;
; FIRST WE'LL DEFINE SOME REGISTER TO USE ;
;-----------------------------------------;
.DEF A = R16   ;GENERAL PURPOSE ACCUMULATOR
.DEF I = R21   ;INDEXES FOR LOOP CONTROL

.ORG $0000

;-----------------------------------------;
; FIRST WE SETUP A STACK AREA THEN SET    ;
; DIRECTION BIT ON PORT-B FOR OUTPUT/SPKR ;
;-----------------------------------------;
START:
  LDI A,LOW(RAMEND)   ;SETUP STACK POINTER
  OUT SPL,A           ;SO CALLS TO SUBROUTINES
  LDI A,HIGH(RAMEND)  ;SETUP STACK POINTER
  OUT SPH,A           ;SO CALLS TO SUBROUTINES

  LDI A,0b1111_1111   ;SET ALL PORTB FOR OUTPUT
  OUT DDRB,A          ;WRITE 1s TO DIRECTN REGS

;--------------;
; MAIN ROUTINE ;
;--------------;
LEDONOFF:
  SER A
  OUT  PORTB,A
   RCALL DELAYLONG
  CLR A
  OUT PORTB,A
   RCALL DELAYLONG
  RJMP LEDONOFF


DELAYLONG:
; =============================
; Delaying approximately 1 sec at 8Mhz.
; This code has been created with  “AVR Delay Loop Generator V1.2?.
          ldi  R17, $48
WGLOOP0:  ldi  R18, $BC
WGLOOP1:  ldi  R19, $C4
WGLOOP2:  dec  R19
          brne WGLOOP2
          dec  R18
          brne WGLOOP1
          dec  R17
          brne WGLOOP0
; =============================
RET