Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Multi-functional shield on Arduino Uno

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-ARDUINO
View previous topic :: View next topic  
Author Message
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Wed Feb 18, 2015 5:01 pm    Post subject: Multi-functional shield on Arduino Uno Reply with quote

This is the hardware:



And here the software to drive the board:

First a atmega328p_pins.inc to translate most of the Arduino pins to Bascom-pins

Code:
'Arduino_uno_pins.inc

D0 Alias Portd.0
D1 Alias Portd.1
D2 Alias Portd.2
D3 Alias Portd.3
D4 Alias Portd.4
D5 Alias Portd.5
D6 Alias Portd.6
D7 Alias Portd.7
D8 Alias Portb.0
D9 Alias Portb.1
D10 Alias Portb.2
D11 Alias Portb.3
D12 Alias Portb.4
D13 Alias Portb.5
D14 Alias Portc.0
D15 Alias Pinc.1
D16 Alias Pinc.2
D17 Alias Pinc.3
D18 Alias Portc.4
D19 Alias Portc.5
 


And here the main program with several tests of the hardware

Code:
'Arduino Uno -  Multi-functional board

$regfile "m328pdef.dat"
$crystal = 16000000
$hwstack = 64
$swstack = 64
$framesize = 64

Dim X As Word

Const _shift_delay = 20                                     'shift out delay in microseconds

'beeper = d3 = portd.3 - 0=active
'led1 = d13 = portb.5
'led2 = d12 = portb.4
'led3 = d11 = portb.3
'led4 = d10 = portb.2
'S1 = D15 = pinc.1
'S2 = D16 = pinc.2
'S3 = D17 = pinc.3

$include "arduino_uno_pins.inc"

Config D3 = Output                                          'beeper
Config D13 = Output                                         'led1
Config D12 = Output                                         'led2
Config D11 = Output                                         'led3
Config D10 = Output                                         'led4
Config D15 = Input                                          'switch1
Config D16 = Input                                          'switch2
Config D17 = Input                                          'switch3

Data_out Alias Portb.0                                      ' SER - first 595 pin 14
Latch_out Alias Portd.4                                     ' RCLK- all chips pin 12
Clock_out Alias Portd.7                                     ' SRCLK- all chips pin 11
                                                            'Chip 1 QH' -> 2nd SER
                                                            'OE connected to ground
Config Clock_out = Output                                   'set output to 595.
Config Data_out = Output                                    'set output to 595.
Config Latch_out = Output                                   'set output to 595.

Set Clock_out                                               'switch off 595
Reset Data_out                                              'switch off 595
Reset Latch_out                                             'switch off 595

Dim Pattern As Word
D3 = 1                                                      ' beeper off

Declare Sub Send595(byval Pattern As Word)

'clear display

'              SSSSSSSS      DDDD
'              .GFEDCBA      1234
   Pattern = &B11111111_0000_0000                           'segments active low, display active high
   Call Send595(pattern)

' beeper on/off

D3 = 0                                                      'beeper
Wait 1
D3 = 1
Wait 1

' leds running

For X = 1 To 20
   D13 = 0
   Waitms 100
   D13 = 1
   D12 = 0
   Waitms 100
   D12 = 1
   D11 = 0
   Waitms 100
   D11 = 1
   D10 = 0
   Waitms 100
   D10 = 1
   Waitms 100
Next X

'beep for switch press

D3 = 0                                                      'beeper
Wait 1
D3 = 1
Wait 1

' switches

For X = 1 To 6500
If D15 = 0 Then D13 = 0                                     'S1 - Led1
If D16 = 0 Then D12 = 0                                     'S2 - Led2
If D17 = 0 Then D11 = 0                                     'S3 - Led3
Waitms 1
Next X

'beep for switch press

D3 = 0                                                      'beeper
Wait 1
D3 = 1

'leds off

D13 = 1
D12 = 1
D11 = 1
D10 = 1

'display, show 1234 - found in www.mcselec.com - work of Ian Dobson

Do
'segment and display
'              SSSSSSSS      DDDD
'              .GFEDCBA      1234
   Pattern = &B11111001_0000_0001                              '1
   Call Send595(pattern)
   Waitms 5
   Pattern = &B10100100_0000_0010                              '2
   Call Send595(pattern)
   Waitms 5
   Pattern = &B10110000_0000_0100                              '3
   Call Send595(pattern)
   Waitms 5
   Pattern = &B10011001_0000_1000                              '4
   Call Send595(pattern)
   Waitms 5
Loop
End

'-----------------------------------------------------------------------------
Sub Send595(byval Pattern As Word)
   Shiftout Data_out , Clock_out , Pattern , 0 , 16 , _shift_delay       'send pattern
   Set Latch_out                                             'latch shift reg to outputs
   NOP                                                       'wait abit
   Reset Latch_out                                           'latch off, data written
End Sub


 


Parts are found in the www.mcselec.com forum.

Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1161
Location: France

france.gif
PostPosted: Wed Feb 18, 2015 5:42 pm    Post subject: Reply with quote

hello !

it's a good idea to make an alias for the pins !
Quote:
I love and Hate Arduino.
Love, because the shields are an easy way to try , to test, most are cheap and clever.
hate, because Arduino don't speak about port as AVR and Bascom speak.


Where did you find the shield ?

Thanks you
JP
Back to top
View user's profile Visit poster's website
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Wed Feb 18, 2015 6:18 pm    Post subject: Source Arduino Uno shield Reply with quote

On the board a CE stamp so I think it is from Chinese Electronics Very Happy

7,11 euro. Sounds like Ben Good..

Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5920
Location: Holland

blank.gif
PostPosted: Thu Feb 19, 2015 9:58 pm    Post subject: Reply with quote

Thanks for sharing Ben. Very Happy
Indeed a good idea to create an inc file.

_________________
Mark
Back to top
View user's profile Visit poster's website
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Tue Mar 24, 2015 4:24 pm    Post subject: small note on multifunctional board. Reply with quote

One little note on the multifunctional shield.

The display can make a shortcut with the USB connector. In that case segment B of all displays are on.

A piece of tape on the USB connector can prefent this.

Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-ARDUINO All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum