Show Posts
Pages: [1] 2 3 ... 579
1  Using Arduino / Programming Questions / Re: Having issues using an Arduino to emulate a shift register. Details inside. on: Today at 06:29:04 pm
Thanks, that gives me a better idea of what's going on.

Looking at the 4014 data sheet I'm not convinced that code is right, presumably it does work but everything is done on the clock's rising edge not on the load edge.

Anyway I've done a new version.

Code:
// S88 pins setup
#define S88DATAIN 5
#define S88DATAOUT 4
#define S88CLOCK 2
#define S88LOAD 3

#define N_REGS 2
#define N_BITS (N_REGS * 8)

byte S88DataOutShiftRegister[N_BITS];
int rd_index = 0;
int wr_index = 0;

// S88 test data, when this works completely I want to add the wireless stuff to manipulate this data array.
uint8_t S88data[N_BITS] = {
0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
};

void setup() {
  attachInterrupt(0, CLOCK, RISING); // Interrupt stuff for the CLOCK
  pinMode(S88DATAOUT, OUTPUT);
}

void loop() { // No loop stuff because it's all interrupt driven.
}

void CLOCK() {

byte dataInBit = (PIND >> S88DATAIN) && 1;
byte loadBit = (PIND >> S88LOAD)  && 1;

if (loadBit) {    // LOAD (PE pin on 4014) is asserted
// put the test data into the FIFO
for (int i = 0; i < N_BITS; i++) {
S88DataOutShiftRegister[i] = S88data[i];
}
rd_index = 0;
wr_index = 0;
} else { // LOAD is not asserted
// Get bit from upstream unit and add to FIFO
S88DataOutShiftRegister[wr_index++] = dataInBit;
wr_index = wr_index < N_BITS ? wr_index : 0;
}

// setup data out so it's at the right level for the downstream unit when the next clock occurs
if (S88DataOutShiftRegister[rd_index++])
PORTD |= (1 << S88DATAOUT);
else
PORTD &= ~(1 << S88DATAOUT);

rd_index = rd_index < N_BITS ? rd_index : 0;

}

As you say I don't have that gear so can't test it, I can't really set up two Arduinos (or indeed any hardware) right now either as I'm in the process of building my workshop and everything is in total disarray.

Anyway you don't have to go this way of course, you may feel more comfortable with the more inline approach used by GuyA's code, but it's worth plugging this in to see what happens.

______
Rob
2  Products / Arduino Due / Re: Building an LCD TFT library for Arduino DUE on: Today at 06:18:05 pm
Have you got a frame rate (or update time) for drawing a full bitmap?

______
Rob
3  Using Arduino / Networking, Protocols, and Devices / Re: Serial communication (Arduino Mega 2560) on: Today at 03:29:25 am
Quote
Moreover, the Serial1, Serial2 and Serial3 functions do not give any output on the screen.
Are they connected to a serial port on the PC? If so how, because that would require 3 USB->serial converter cables or dongles.

______
Rob
4  Using Arduino / Programming Questions / Re: Having issues using an Arduino to emulate a shift register. Details inside. on: April 17, 2014, 10:29:11 pm
Just thinking off the top of my head here, this code should be a lot faster, it only implements the shift reg part not LOAD which AFAICT did nothing yet anyway as there was no code to output to the parallel pins. With no outputs to the parallel pins how are you testing this?

Code:
// S88 pins setup
#define S88DATAIN 5
#define S88DATAOUT 4
#define S88CLOCK 2
#define S88LOAD 3

#define N_REGS 3
#define N_BITS (N_REGS * 8)

uint16_t S88DataOutShiftRegister[N_BITS];
int rd_index = 0;
int wr_index = 0;

void setup() {
  attachInterrupt(0, CLOCK, CHANGE); // Interrupt stuff for the CLOCK and LOAD
  attachInterrupt(1, LOAD, RISING);
  pinMode(S88DATAOUT, OUTPUT);
 
  for (int i = 0; i < N_BITS; i++) {
S88DataOutShiftRegister[i] = 0;
  }
 
}

void loop() { // No loop stuff because it's all interrupt driven.
}

void CLOCK() {

byte dataBit = (PIND >> S88DATAIN) && 1;
byte clockBit = (PIND >> S88CLOCK)  && 1;

if (clockBit) {   // If rising edge, write top FIFO bit to S88DATAOUT
if (S88DataOutShiftRegister[rd_index++])
PORTD &= ~(1 << S88DATAOUT);
else {
PORTD |= (1 << S88DATAOUT);
}
rd_index = rd_index < N_BITS ? rd_index : 0;

} else {   // If falling edge, read S88DATAIN -> Put the data into the FIFO
S88DataOutShiftRegister[wr_index++] = dataBit;
wr_index = wr_index < N_BITS ? wr_index : 0;
}
}

void LOAD() // Setup the S88data arrays / shift registers... Now it's ready to be send!
{
}

I'm pretty sure it will be faster to represent the bits in a byte array, that way there is no shifting of them every time you get a new bit. And my making that array a FIFO there is nothing to do but update the read and write index variables.

I'm sure there is still much room for improvement, this is just a first pass.

______
Rob
5  Using Arduino / Programming Questions / Re: Having issues using an Arduino to emulate a shift register. Details inside. on: April 17, 2014, 09:52:57 pm
Quote
I thought about seeing if there's a sketch for Arduino to make it a logic analyzer, and maybe that'd help give me a little insight.
I believe there are such sketches, they won't be very fast I think but it would be worth having a look.

A logic analyser is the most useful tool you can have for embedded work, hands down. You can get a Saleae Logic 8 for $149 (less for the new 4-channel one) or a clone of it for about $20. I prefer to support the Saleae guys, but if you don't have the cash you can get the clone and still use the Saleae software.

Quote
directly manipulate the pins so I can pump the data out faster. I don't know if that'd solve the problem though. I've read there's some overhead with using digitalWrite as opposed to direct manipulation.
The code is already using direct manipulation, so in that respect there is nothing to be gained. Yes the code is simple but also quite inefficient I think. Interrupts are not the fastest way to do this and all those shift operations will be slow. There must be a better way but I haven't thought of it yet.

______
Rob
6  Using Arduino / Programming Questions / Re: Having issues using an Arduino to emulate a shift register. Details inside. on: April 17, 2014, 07:36:38 pm
Quote
Maybe the Arduino isn’t fast enough to keep up with the controller?
How fast is the incoming data?

How about you post the actual code you are using, or is it the same as GuyA's?

I haven't analysed it yet but that code does not look too clever to me, there is a HUGE amount of <<'s involved and an ISR is not the fastest way to do stuff either.

______
Rob
7  Using Arduino / Microcontrollers / Re: FT232 vs 16u2 on: April 17, 2014, 01:56:04 am
Yeah all good points, so historically it made sense, just not so much any more.

______
Rob
8  Using Arduino / Microcontrollers / Re: FT232 vs 16u2 on: April 16, 2014, 10:35:33 pm
Long  answer: Because it looks like a serial port to the PC application I can only assume they did what most people do, equate "serial" with "RS232", either because they didn't know any better (unlikely) or maybe as a marketing ploy because they knew most people make that connection.

I can't really think that either of those options is likely, after all anyone designing a board with these chips would know the difference and certainly those designing the chip would know.

So that brings me back to a marketing reason.

Short answer: No idea smiley


______
Rob
9  Products / Arduino Due / Re: Small-footprint Due on: April 16, 2014, 07:42:01 pm
The SAM has a SHDN pin that is supposed to be used to shut down external regulators, that may imply that this should be done to get the best low power operation, but I think it's just to kill external circuitry, the CPU itself has this well handled.

One would assume as you say that the current used on the VDD pins is next to nothing, in fact if you look at Fig 46-4 they have all the VDD pins shorted to GND for testing the VDDBU current, so it's fair to say there is nothing but some leakage current on those pins under a normal shutdown situation.

______
Rob
10  Using Arduino / Microcontrollers / Re: FT232 vs 16u2 on: April 15, 2014, 07:00:39 am
I still use the FT232Rx, I don't have to program it (and allow for an ISP header) and it "just works". I've been tempted to try the newer smaller versions but it if ain't broke...

______
Rob
11  Community / Bar Sport / Re: Adafruit's new website on: April 15, 2014, 06:55:48 am
Seems fine to me (speed wise) over my mobile phone connection. No comment yet on navigation.

______
Rob
12  Using Arduino / Programming Questions / Re: How to use unsigned char arrays with external SRAM? on: April 15, 2014, 06:48:24 am
Jeez I'm confused and I know nothing about TinyBasic, but if you have two arrays of data, one in the AVR RAM and the other in external RAM write a loop that scans the AVR array and compares it with the external array, one byte at a time, similar to what you did in the first post.

You cannot use the = operator (well you could if you overload it but that's out of your league I think).

Quote
only if TinyBASIC would still work by using this method which I am not sure about)
What does TB have to do with this? Is this a C question or a TB question? Does the code have to be written in TB?

Quote
need a method to make an internal array equal the external SRAM array without bringing the data in
Now I'm even more confused, do you want to move the AVR data to the external RAM (or VV)?

______
Rob
13  Products / Arduino Due / Re: Anyone using CMSIS? How to get started? on: April 14, 2014, 06:44:45 pm
I've done quite a lot of programming on LPCs (great chips and environment BTW) and I confess that I'm still not 100% sure how useful CMSIS is. Yes it's supposed to be an abstraction layer for the ARM, but how many people actually work with the ARM core? Answer, almost none.

Here is a snippet from my main() func

Code:
// Enable AHB clock for GPIO ports
LPC_SYSCON->SYSAHBCLKCTRL |= _BV(AHB_GPIO1) | _BV(AHB_GPIO0);

The definitions here are from an H file in the CMSIS folder, but this is very LPC specific, no way that code will run on a SAM or ST. So there is a small abstraction level there but not much and certainly not portable.

Here is some more setup code

Code:
LPC_SYSCON->SYSOSCCTRL = 0;
LPC_SYSCON->PDRUNCFG &= ~(1 << 5);
LPC_SYSCON->SYSOSCCTRL = 1;

This is obviously dealing with the ARM core which will be the same on all M0 chips, but the left values at least have an LPC_ prefix so once again this code won't work on another family, even is if all boils down to the same address, offsets and code.

And this is working directly with the M0 core, almost nobody does that except maybe a little setup code, most code is either generic C/C++ that will run anywhere or deals with the chip's peripherals which are totally different on all families.

So for the average user I see almost no benefit to CMSIS, they need a real HAL framework like the Arduino.

Quote
NXP gets points for removing restrictions on the free version of their LPCXpresso IDE, namely C++ support is now included, and code size limitations eased or removed.
Yes, I ported most of the Arduino core to LPC122x, but that was before they opened up the compiler and I had to do it all in C so things like Serial.begin() had to be SerialBegin() etc. I got it to the stage where you could run a simple Arduino sketch with very few changes to the code.

Now that C++ is free I've started porting the code to C++. I haven't got far with the conversion though because I have too many other things to do.

______
Rob
14  Using Arduino / Project Guidance / Re: multiple devices on one serial port? on: April 14, 2014, 10:04:03 am
Quote
the devices are all the same and send their data once every second  at 9600baud. i have no influence on these devices except for powering them on and off.
Then you are out of luck, there are many ways to do this with a single serial port but they all require you to write a protocol that runs on all connected devices, as you have no control over most of them there's little you can do except have a heap of serial connections or control the power to each device and cycle through them.

As for using software serial, I don't think it works well (at all?) with 10 inputs.

______
Rob
15  Development / Other Hardware Development / Re: Arduino shield pins and ICSP header mismatched height on: April 14, 2014, 09:24:40 am
I often wondered how well that SPI header worked as it's pins are a different length to those on the shield pass-through headers.

______
Rob
Pages: [1] 2 3 ... 579