Show Posts
Pages: [1] 2 3 4
1  Using Arduino / LEDs and Multiplexing / 16x32 Matrix flashing, coding help on: August 15, 2014, 02:52:16 am
Good morning all,

I am writing some code for a 16x32 matrix I have, it works of a 16bit shift register for the column bits data, and a 4 to 16 line decoder to set the row to write the data to.

I am somewhere near with it, but when I try and display just the number 2 ( which I have defined as a bit array, ) it just flashes the matrix at a high rate, I know the routine is a bit rough, and I am sure its just the position of my update, latch or something but I would really appreciate some advice

many thanks

Rich

Code:
byte number2[] ={
  B00000000,
  B01111110,
  B01111110,
  B00000110,
  B00000110,
  B00000110,
  B00000110,
  B01111110,
  B01111110,
  B01100000,
  B01100000,
  B01100000,
  B01100000,
  B01111110,
  B01111110};
 
int clockPin = 2;
int reddataPin = 3;


void setup() {
  // put your setup code here, to run once:
pinMode(4,OUTPUT);   //  Sets latch pin as output
pinMode(5,OUTPUT);  // Sets OE pin as output

pinMode(clockPin, OUTPUT);
pinMode(reddataPin, OUTPUT);

pinMode(34,OUTPUT);  // Sets Address row pins as outputs
pinMode(35,OUTPUT);
pinMode(36,OUTPUT);
pinMode(37,OUTPUT);

 shiftOut(reddataPin, clockPin, MSBFIRST, 0);  // Clears the display upon boot up
  shiftOut(reddataPin, clockPin, MSBFIRST, 0);
  shiftOut(reddataPin, clockPin, MSBFIRST, 0);
  shiftOut(reddataPin, clockPin, MSBFIRST, 0);
  #define pinport PIOC                          // defines the address pins on PORT C
}

void loop() {
  // put your main code here, to run repeatedly:


 
for (int j=0; j<15; j++){                   //Loop For getting new row data


       for (int i = 0; i<16; i++) {              // Loop for new column address
   
   
       pinport -> PIO_SODR = i << 2 ;   // set row Address eg, B1010   
 
      digitalWrite(4,LOW);    // Set Latch Low
 
 
      shiftOut(reddataPin, clockPin, MSBFIRST, 0);    // Shift BYTE 1 onto register
      shiftOut(reddataPin, clockPin, MSBFIRST, 0);    // Shift BYTE 2 onto register
      shiftOut(reddataPin, clockPin, MSBFIRST, 0);    // Shift BYTE 3 onto register
      shiftOut(reddataPin, clockPin, MSBFIRST, number2[j]);    // Shift BYTE 4 onto register
 
 
 
      digitalWrite(5,HIGH);   // Set Output Enable HIGH ( Turn off the display while new data is latched into it)
      digitalWrite(4,HIGH);      // Set Latch HIGH to latch the new data from the register to the display
      digitalWrite(5,LOW);    // Set Output Enable LOW to show the new data
 
      pinport -> PIO_CODR = i << 2 ;  // clear pin    // Return Row address Pins to B0000

 
      }
 
  }

}

2  Products / Arduino Due / Re: Arduino DUE How to Direrct Port Access? on: August 14, 2014, 09:46:41 am
OK, great,

So I have a row of 4 pins that I want to send a WORD to, how would I go about setting the data for that to be sent to the 4 pins,

they would be PORT C  slot 2,3,4,5 so easy to send the word to but how would I set the data to send?

eg, b1001 to PORT C 2,3,4 and 5

Cheers

Rich
3  Products / Arduino Due / Re: Arduino DUE How to Direrct Port Access? on: August 13, 2014, 08:08:18 am
HI Mark,

many thanks for the reply I will have a go at a simple example of this and see what results I get, I am assuming that I will need to send a 32bit mask to the ports ?

eg


  pinMode (32, OUTPUT) ;
  D -> PIO_SODR = B11111111111111111111111111111111 ;   // set pin
  delay (1) ;
  D -> PIO_CODR = B1111111111111111111111111111111 ;  // clear pin
4  Products / Arduino Due / Arduino DUE How to Direrct Port Access? on: August 13, 2014, 07:02:42 am
Hi All,

Just a quick question,

I am relatively new with the Arduino but have some experience with the direct port access on the UNO etc,

I have now moved to the DUE and IDE 1.5.7 I think , DDRD and PORTD commands no longer work, I get a" DDRD was not declared"

Is this an IDE thing or a processor command thing?

Can anyone help with what the direct port access commands are now?

Many thanks all

Rich
5  Products / Arduino Due / Re: [ now published on github ] Building a CAN API for Arduino DUE on: July 30, 2013, 02:21:52 am
Hi Thanks for the VAriant Files,

I replaced the standard arduino Variant Files with these and i still cant compile it,

The first error is that variant.h doesnt exist. i have checked spelling of the file and location (in the variants folder i assuem?) seems ok

See below, i am completely confused, i dont usually have issues like this but i have not used the due much as of yet,

Code:
Arduino_Due_CAN_Sample_1.ino:7:21: error: variant.h: No such file or directory
In file included from \\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:72,
                 from Arduino_Due_CAN_Sample_1.ino:8:
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/sn65hvd234.h:34: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/sn65hvd234.h:37: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/sn65hvd234.h:39: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/sn65hvd234.h:40: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/sn65hvd234.h:41: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/sn65hvd234.h:43: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/sn65hvd234.h:44: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/sn65hvd234.h:46: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/sn65hvd234.h:47: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/sn65hvd234.h:48: error: expected `)' before 'Rs'
In file included from Arduino_Due_CAN_Sample_1.ino:8:
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:76: error: 'uint8_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:77: error: 'uint8_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:129: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:130: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:131: error: 'uint8_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:132: error: 'uint8_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:144: error: 'uint8_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:151: error: ISO C++ forbids declaration of 'Can' with no type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:151: error: expected ';' before '*' token
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:159: error: 'uint16_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:160: error: 'uint16_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:161: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:161: error: 'uint32_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:167: error: expected `)' before '*' token
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:213: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:213: error: 'uint16_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:214: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:215: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:216: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:217: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:218: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:219: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:220: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:220: error: 'uint32_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:221: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:221: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:222: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:222: error: 'uint32_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:223: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:223: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:224: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:224: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:224: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:225: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:225: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:226: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:226: error: 'uint32_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:227: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:227: error: 'uint32_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:232: error: 'uint32_t' does not name a type
Arduino_Due_CAN_Sample_1.ino: In function 'void loop()':
Arduino_Due_CAN_Sample_1:39: error: 'class CANRaw' has no member named 'init'
Arduino_Due_CAN_Sample_1:39: error: 'SystemCoreClock' was not declared in this scope
Arduino_Due_CAN_Sample_1:40: error: 'class CANRaw' has no member named 'init'
Arduino_Due_CAN_Sample_1:60: error: 'CAN_TCR_MB0' was not declared in this scope
Arduino_Due_CAN_Sample_1:63: error: 'class CANRaw' has no member named 'mailbox_get_status'
Arduino_Due_CAN_Sample_1:63: error: 'CAN_MSR_MRDY' was not declared in this scope
Arduino_Due_CAN_Sample_1:68: error: 'class CANRaw' has no member named 'mailbox_read'
Arduino_Due_CAN_Sample_1:70: error: 'struct RX_CAN_FRAME' has no member named 'data'
Arduino_Due_CAN_Sample_1:71: error: 'struct RX_CAN_FRAME' has no member named 'data'
Arduino_Due_CAN_Sample_1:72: error: 'struct RX_CAN_FRAME' has no member named 'data'
Arduino_Due_CAN_Sample_1:73: error: 'struct RX_CAN_FRAME' has no member named 'data'
Arduino_Due_CAN_Sample_1:74: error: 'struct RX_CAN_FRAME' has no member named 'data'
Arduino_Due_CAN_Sample_1:75: error: 'struct RX_CAN_FRAME' has no member named 'data'
Arduino_Due_CAN_Sample_1:76: error: 'struct RX_CAN_FRAME' has no member named 'data'
Arduino_Due_CAN_Sample_1:77: error: 'struct RX_CAN_FRAME' has no member named 'data'
6  Products / Arduino Due / Re: [ now published on github ] Building a CAN API for Arduino DUE on: July 29, 2013, 10:35:14 am
Hi All.

First off, Fantastic Effort.

I am having real trouble getting the example 1 to compile,

Getting a lot of errors that i think stem from incorrect Variant file, does anyone have the variant file i need? as i cant find it on Collins Git page

Cheers

Rich
7  Using Arduino / LEDs and Multiplexing / Re: VC064T-16 16x32 Matrix control Anyone? on: March 24, 2013, 03:40:54 pm
no i seem to be at a loss with it too, im not advanced enough to understand how to control them looking at the timing chart on the datasheet

I will have to keep digging
8  Using Arduino / LEDs and Multiplexing / Re: UCS1903 Library or compatible? on: March 22, 2013, 11:52:18 am
Thanks for that Garcia, i understand what it does but at the moment i am a little bit behind on the coding, the library i found on Github works great and usues simple functions to call, similar to what you have mentioned about the array, but works in the way led.set("led number" "red value" "green value" "blue value")

Rich
9  Using Arduino / LEDs and Multiplexing / Need help with a Boolean operation and simplification on LED Keypad on: March 22, 2013, 06:56:11 am
Hi All, i am contructing a CAN based keypad for a motorsport vehicle,

Currently i am merging some code to read a keypad and switch on a corresponding LED above it

I am having trouble with the Boolean "i" ststement as it requires 2 pushes of a keypad to extinguish or illuminate an led, if the same operation has been perfomed on a diffrerent key

I understand why it is doing it, as it needs to switch from i = 1 to i = 0 before it can switch an LED on again, i just cant seem to get my head round doing it, also i would like to simplify it a little but not sure how.

Hope you are able to help

Many thanks

Rich

Code:


#include <Keypad.h> // Include Keypad library
#include <Ucs1903.h> // Include LED Controller Library



#define NUM_LEDS 4  // Defines Number of LED's
#define PIN 13      // Defines Data Pin for LED's

Ucs1903 ledStrip(PIN, NUM_LEDS);


boolean i = 0; //Defines Switch State

int j = 0;   // Variable to Define which LED to Switch


const byte ROWS = 5; //defines number of rows
const byte COLS = 3; //defines number of columns

char keys[ROWS][COLS] = {  //define the symbols on the buttons of the keypads as an array
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'0','A','B'},
  {'C','D','E'},
};

byte rowPins[ROWS] = {9, 8, 7, 6, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {12, 11, 10,}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );




void setup(){


keypad.addEventListener(keypadEvent); //Listen for a keypad Press
}
  
void loop(){
  char key = keypad.getKey();
  
  if (key) {
}
  
     if (i==1){
  ledStrip.setLed(j, 0, 0, 75);  // Turn on LED if Putton has been Pressed
  }
  
   else
    ledStrip.setLed(j, 0, 0, 0);   // Else Turn LED Off
 
    
    ledStrip.show();   // Send Data to LED Controller
    
}


void keypadEvent(KeypadEvent key){         //What to do when a particular Key is pressed
  switch (keypad.getState()){
    case PRESSED:
      switch (key){
        case '1':  i = !i, j= 0; break;
        case '2':  i = !i, j= 1; break;
        case '3':  i = !i, j= 2; break;
        case '4':  i = !i, j= 3; break;
        case '5':  break;
        case '6':  break;
        case '7':  break;
        case '8':  break;
        case '9':  break;
      }
    break;
  }
    
}
10  Using Arduino / LEDs and Multiplexing / Re: UCS1903 Library or compatible? on: March 22, 2013, 05:23:41 am
Thanks Alll, i have now found a Library to do this smiley

Rich
11  Using Arduino / LEDs and Multiplexing / Re: UCS1903 Library or compatible? on: March 22, 2013, 03:10:26 am
http://code.google.com/p/fastspi/

This is the site i got the code from, it works fine with the 1903 strip, i just cant get my head around the commands used in the examples there

If i simply wanted to set led 1 to Red for example, what is the simpilest way to do it, once i understand the basic principals of using the keywords i will be fine i think

I hope this all helps in some answers

Cheers

Rich
12  Using Arduino / LEDs and Multiplexing / Re: UCS1903 Library or compatible? on: March 21, 2013, 04:04:48 am
The testLeds_2 folder actually contains support for the UCS1903 so i have it working on the bench and changing colour, but i dont understand the example code as i posted above,

The TLC5490 was simple, LED.Set and LED.update were simple commands, but i dont understand the commands used to set the data, the layout of the data its expecting to see, and the command to update the data in the chip?

Im not an experienced programmer and ive been racking my brains for hours trying different keywords in the list to get it to do a simple "set Led 1 red" for example

Cheers

Rich
13  Using Arduino / LEDs and Multiplexing / UCS1903 Library or compatible? on: March 20, 2013, 11:12:25 am
Hi All, i have some 1903 RGB strip , 9 LED's long, and i would like to address each LED colour individually, i,e, set LED 1 to orange, 3 to red, 4 to greet etc

I have some experience with the TLC5490 but these are a different kettle of fish, i have a Fast Spi library i discovered on the net, but the keywords dont seem to reference to this particular chip

I have this so far

Code:

#include "FastSPI_LED2.h"




#define NUM_LEDS 4

struct CRGB { byte r; byte b; byte g; };

struct CRGB leds[NUM_LEDS];


UCS1903Controller400Mhz<3> LED; // Sets the Controller to be UCS1903



void setup()
{

LED.init();  //Initialise LED Controller
}


void loop() {

for(int i = 0; i < 3; i++) {
for(int iLed = 0; iLed < NUM_LEDS; iLed++) {
memset(leds, 0,  NUM_LEDS * sizeof(struct CRGB));
switch(i) {
case 0: leds[iLed].r = 255; break;
case 1: leds[iLed].g = 255; break;
case 2: leds[iLed].b = 255; break;
}

LED.showRGB((byte*)leds, NUM_LEDS);;

delay(100);
}
}

}



This is an expample provided which just runs the led's through each of the 3 colours continuousle, but i simple want to write a value and send it, sorry i cant offer more insight

Keywords supplied,


start   KEYWORD2
stop   KEYWORD2
init   KEYWORD2
setLeds KEYWORD2
setChipset KEYWORD2
setCPUPercentage KEYWORD2
setRGBData KEYWORD2
getRGBData KEYWORD2
setDirty KEYWORD2
show KEYWORD2
getCounter KEYWORD2
clearCounter KEYWORD2
getCycleTime KEYWORD2
getCycleTarget KEYWORD2

Thanks all

Rich
14  Using Arduino / LEDs and Multiplexing / VC064T-16 16x32 Matrix control Anyone? on: December 04, 2012, 06:50:57 am
Hi all, i have recently aquired 4 off 16x32 dual colour LED Matricies from a clearance,

The datasheet shows the control chip to be from Vissem but little else,

There is a timing sheet that shows the control to be Via Serial Data, and Address A0 to A3, maybe a BCD?

Has anyone ever used one? o know of some libraries i could adapt?  there seems to be very little info on the web

many thanks to all

Rich
15  Using Arduino / Networking, Protocols, and Devices / Re: Running 2 serial devices from an Arduino? CAN chip and TLC5940 on: December 03, 2012, 08:19:53 am
Well, it seems that it works on BIT_BANG, but it doesnt upate the LED's, fast enough

How can i run Both the MCP and TLC chips from the SPI bus, the CS and B;ank pins are now separate,

Do i need to add some clock timing between the devices?

Cheers
Rich
Pages: [1] 2 3 4