Show Posts
Pages: [1] 2 3 ... 12
1  Using Arduino / Networking, Protocols, and Devices / Re: Arduino UNO SPI Library + MCP3208 : request for suggestions on: January 10, 2014, 08:29:52 pm
I totally nailed the linearity issue with a Unity Gain Amplifier :-)

This is what I get now:


I couldn't be more happy with the result :-)
Now I got full linearity on the whole analog input range! An LM358 in Unity Gain AMpli configuration did the trick on the input channel being fed to mcp3208. Well I still have to power the OpAmp with more then 5V ... which is a new issue I have to attack now, I'd really love to settle down on a single 5V power supply only :-(
2  Using Arduino / Networking, Protocols, and Devices / Re: Arduino UNO SPI Library + MCP3208 : request for suggestions on: January 09, 2014, 09:08:53 am
What voltage are you actually feeding into the device ?

I'm feeding it with 5V from Arduino itself. I have a cheap voltmeter, so my 4.90V reading maybe inaccurate but still pretty close to 5.0V. I consider that a minor issue. I'm more concerned with the non-linearity of the last part of the curve at values higher then 4.3V ... I supposed at first that the MCP3208 should output more linearly the whole range through.

I'm reading right now about a Unity Gain Amplifier, could that be related to this case? I'm still not very confident with all that low/high_impedance input stuff, I'm open to suggestions about that.
3  Using Arduino / Networking, Protocols, and Devices / Re: Arduino UNO SPI Library + MCP3208 : request for suggestions on: January 09, 2014, 09:03:58 am
12 bit  A/D  only goes to 4095  maximum output.

Well, I'm cool with that. Btw, the 4095 is confirmed, not the "zero" value, the lowest digital value I get is 3 (almost 0). But that's not an issue :-)
4  Using Arduino / Networking, Protocols, and Devices / Re: Arduino UNO SPI Library + MCP3208 : request for suggestions on: January 08, 2014, 12:53:30 pm
In the meanwhile I managed to get more linear outputs adding a bypass capacitor to the circuit as suggested in the datasheet.

That really helped a lot but not solved a rather annoying issue in the upper voltage range. I'm feeding a +5v Vref to the ADC and I get a pretty linear output in the range 0.0-4.3V but after that the linearity is lost.


I assume it's because this chip is most probably a Chinese counterfeit.
Please, someone tell me if even the genuine Microchip MCP3208 do show that curve at "high" voltage (I doubt that).
5  Using Arduino / Networking, Protocols, and Devices / Re: Arduino UNO SPI Library + MCP3208 : request for suggestions on: January 08, 2014, 10:48:35 am
I have to correct myself about the clock issue. mcp3208 is not happy with clocks under 10KHz not 10MHz. My mistake, didn't read well the datasheet. So, SPI_CLOCK_DIV4 is already good enough :-)
6  Using Arduino / Networking, Protocols, and Devices / Re: Arduino UNO SPI Library + MCP3208 : request for suggestions on: January 08, 2014, 09:53:43 am
The gap at the end is not from SPI.end() (you call that after you set CS high again) but from the call to digitalWrite().

Right, SPI.end() in the timing_graph is just a typo.

So I assume I will live with all that waste if I don't want to rewrite the lib my own, right? Not that it disturbs anything as of now :-)
7  Using Arduino / Networking, Protocols, and Devices / Arduino UNO SPI Library + MCP3208 : request for suggestions on: January 08, 2014, 08:46:57 am
Hi everybody,
 I am playing with a Microchip MCP3208 ADC SPI converter which is currently converting a 10K Pot input values to my Arduino UNO. MCP3208 is a 12bit resolution ADC, its SPI protocol needs some more bits in order to know how to answer to the Master, and I hadd to add quite a few more at the beginning in order to get those 12bits output at the end inside a few 8bits blocks to properly feed an SPI.transfer() function.

The logic analyzer shows me this:


The code generating that is:
Code:
#include <SPI.h>
#include "pins_arduino.h"

void setup (void) { }

void loop (void)
{
  byte a;
  byte b;
  byte c;
  digitalWrite(SS, HIGH);
  SPI.begin ();
  SPI.setDataMode(SPI_MODE1);
  digitalWrite(SS, LOW);    // SS is pin 10
  a = SPI.transfer(B00000110);
  b = SPI.transfer(B01000000);
  c = SPI.transfer(B00000000);
  digitalWrite(SS, HIGH);
  SPI.end();
}

I have a few questions someone may answer. Just out of curiosity. Everything works, I'd only like to know some more.

It's obvious there's no way to make spi.transfer() transfer more then 8bits at a time, and I assume there's no way to make those transfer more "tight" ... I mean, without generating those gaps between each 8bits pack, right? The mcp3208 doesn't complain, it still waits Clock signaling in order to answer back with anything at all. I'm just curious.

There's also that last gap at the end (the one where I wrote a green SPI.end()). Actually I assume It's related to digitalWrite(SS, HIGH) only. I wonder if that's a "feature" of SPI Library or just a "side effect". It's obviously not needed for the SPI to work.

Well, happy to read some hints about that.
    Cheers :-)

Actually I have another question regarding the spi_clock_divider. As I read I can only force the UNO to clock the SPI at 8MHz. SPI.setClockDivider(SET_CLOCK_DIV2) makes it clock at 16MHz/2=8MHz which is still slower then the 10MHz minimum required by MCP3208 for reliable conversions.
I already noticed some quite offset values when running at default SET_CLOCK_DIV4, I will investigate more in that but I'd really like to hear something from the community about this issue :-)
8  Using Arduino / Microcontrollers / Re: what does the atmega uc do during every clock cycle? on: July 26, 2013, 05:28:59 am
This is all much easier to grasp on something like a PDP11, where the PC and SP are just ordinary registers, and there haven't been any "optimizations" done to squeeze 32 registers into 4bits of identifier in the instruction.  (or make everything happen in "one clock cycle"; it's really useful to think of multiple phases of each instruction taking "as long as needed", and letting the HW designer figure out how to make that happen in half a clock cycle.  You can probably find a good description somewhere of what an 8051 does with each of the 12 clocks that make up ONE instruction "cycle" in THAT architecture.  Or the 4 clocks of an 8080.  etc.)

I'll look into that, it may prove usefull.

Btw, if someone is familiar with Bell Labs' Cardiac ( http://www.scientificsonline.com/cardiac-illustrated-computation-aid.html ) it will be clear what I have in mind when talking about "educational approach".
9  Using Arduino / Microcontrollers / Re: what does the atmega uc do during every clock cycle? on: July 25, 2013, 04:01:02 pm
...essentially it boils down to a chip architectural question.
Right, and I'd like to be specific on the atmega family.

Quote
Some assembly language guides/books for the AVR line may also reveal specifics.
Do you reckon "Atmel AVR Microcontroller Primer: Programming and Interfacing" of Barrett and Pack, "AVR, an introductory course" of J.Morton or "AVR Mikrocontroller Praxis" of Volpe and P.Volpe are good readings in this regard?

10  Using Arduino / Microcontrollers / Re: what does the atmega uc do during every clock cycle? on: July 25, 2013, 03:54:17 pm
I think section 7 of the datasheet describes pretty well what happens.
That's it, that's the point! Section 7 is the topic, the way it's exposed in the datasheet is the limit (to me, at least) I want to overcome.

E.g. A statement like "In a typical ALU operation, two operands are output from the Register File, the operation is executed, and the result is stored back in the Register File – in one clock cycle." does not make clear if each and every clock cycle simply does that and that only. It's misleading to someone who doesn't know how it really works in the first place. It's a correct statement, of course, but not much educational :-(
Every chapter that follows up is filled with precious and complete informations about every detail of the chip, but the way it's exposed makes the task of learning how it really works a bit daunting.

And yes, of course, I'm learning AVR assembly on the way, that's what I'm doing in my spare time. I'd really like to get more confortable with programming assembly. That's why I'd like to clear my mind about the inner workings of the cpu core.
11  Using Arduino / Microcontrollers / Re: what does the atmega uc does in every clock cycle? on: July 25, 2013, 08:47:49 am
Yeah, general knowledge sucks!

Mmhh.... well, that was not what I meant. Whatever.
12  Using Arduino / Microcontrollers / Re: what does the atmega uc does in every clock cycle? on: July 25, 2013, 08:13:34 am
I don't think there's much that's specific to AVR chips on your list.
Try widening your google searches to more general CPUs, look for graphical cpu simulators, etc.

Evidently I was not clear enough. I'm sorry.

I don't want to broaden my search at all. I don't want to find more generic dissertations about microcontroller architectures, there's way too much out there. I'd like to understand more specifically how the AVR micro-controllers (mainly the atmega family) work instead. And I'm mainly interested (at the moment) on how the CPU works during each clock cycle, how it retrieves instructions from program memory, how it reads/writes data memory, how/when program-counter/ALU/IO-Ports are handled.

I'm going to read some more generic textx about harvard architecture machines too of course, but I'd really like to get to the AVR specifics and get a grip on what's truely going on.

I know Atmel's datasheets are precious in this regard, and I keep reading them through. It's just that they're not meant to be used as a teaching tool, so they lack that teaching approach I'm looking for.
13  Using Arduino / Microcontrollers / what does the atmega uc do during every clock cycle? on: July 25, 2013, 06:22:17 am
I'd like to understand what really happens inside the core when it runs some code. I've found something but not much about that. I wonder if someone here can point me in the right direction.

I'd like to better understand what happens at every clock cycle, how does the program memory work, how is data treated, data flow basics, how the ALU uses data from memory and/or from code... I am pretty shure all of this has already been summarized in the past since the atmega ucontrollers have been used as an educational tool for so long.

But I really can't find much :-( well, maybe "too much" to be exact, Atmel's datasheets are more than complete, but they really treat specifications in a not-"educational way". It's more like a compilation of data and facts than a learning tool.

Maybe there's something aimed more at teaching than simply at enumerating how this stuff work. Any hint?
14  Using Arduino / Programming Questions / avrdude ver.5.11-patch#7610 and ver.5.11: differences? on: July 03, 2013, 04:54:00 am
Hi everybody :-)
I installed and used avrdude ver.5.11-patch#7610 on windows for a while now without a problem.
I noticed today that arduino_1.5.2_beta comes with avrdude ver.5.11 (no mention of the 7610 patch). I wonder if there's any difference with the patched version. At first I'd say no, but I'd like to know more from you here.

Cheers
15  Using Arduino / Sensors / Re: How to sense pool cue relative position? on: April 04, 2013, 10:03:55 am
I'd install two lasers pointers at the back end of the cue. Setting some angle between beams, two lasers dots projected on the wall would be split on some distance, depends on the angle and distance between cue's end and wall...

Interesting suggestion. I'll be looking into that. I'd really like to keep it low profile at first though, and this solution seems a bit overengineered to me.

Anyway, one laser only, projecting a dot onto the back wall may suffice in my case, because my main concern is to evaluate Horizontal/Vertical movements. Correlating it with the Longitudinal displacement would be a well accepted plus, of course :-)
Pages: [1] 2 3 ... 12