NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Project Help and Ideas » first real-time project

February 09, 2010
by mongo
mongo's Avatar

OK, Let's see if this makes sense

The project is for testing a wind turbine through remote sensing.

Here's what it should be:

I recently purchased a pair of transceivers like the ones in the tractor pull monitor. The difference here is that they will be just a data link between a PC and the NK. There will be four testing parameters. 1) actual wind speed via anemometer input. 2) RPM of the turbine. 3)DC voltage produced across a load and 4) DC current across the same load. Wattage can be figured internally.

The reason for the remote is that the test bed is on top of my vehicle and the monitoring will be from a second observation vehicle so it can be under visual at all times. The observer will have the PC and receiver while I maintain steady speeds with the turbine.

I am still at a loss when it comes to programming from scratch so any good advice will be used to help make this thing work.

Construction progress to follow as the parts arrive.

March 06, 2010
by mongo
mongo's Avatar

Well, the radio components finally arrived. Same setup as the tractor pull project. Now I have to figure out how to make them talk the same language.

March 06, 2010
by JKITSON
JKITSON's Avatar

MONGO

MABY TOMORROW I CAN POST THE PROGRAMS I USE FOR THE TRACTOR PULL SLED. I WILL ALSO TRY AND POST THE SCHEMATICS FOR WIRING ALSO...

NOTE (WILL POST THEM IN THE TRACTOR PULL FORUM)

JIM

March 07, 2010
by pbfy0
pbfy0's Avatar

maybe this:

#include "../libnerdkits/uart.h"
#include <pgmspace.h>

void send_data(double windspeed, int rpm, double v, double i){
    printf_P(PSTR("[[{%d}{%i}{%d}{%d}]]"), windspeed, rpm, v, i);
}
March 25, 2010
by mongo
mongo's Avatar

The interface wiring and setup is where I am stuck right now...

There is no communication between the PC or the NK to the RF modules. Signal levels are there but nothing intelligent going through.

I must be missing something obvious but not sure where to start.

March 31, 2010
by BobaMosfet
BobaMosfet's Avatar

mongo-

  1. If you are using the serial interface (default for the nerdkit) you can't use it to talk to the RF Modules at the same time you're connected to the PC. It's one or the other. You probably know that- but it wasn't mentioned so I'm stating it.
  2. Disco the RF module and put a loopback (wire jumper) between your transmit and receive from the MCU, so you can see what you're sending by getting it back and looking at it. Then you'll atleast know you're good or bad up to that point.

Hope that helps move you in the right direction.

BM

March 31, 2010
by mongo
mongo's Avatar

I think it's the baud rate that is giving me troubles. The RF modules look for 19200 BPS and the NK is still trying to run USB speeds. I need to knock down the data speed. It will slow down the communications but that's not a problem. I just haven't figured out how.

I am thinking that either a different crystal of a hack in the UART.H file?

April 29, 2010
by Jer
Jer's Avatar

I would like to use the built in 16bit counter. All I need is to count external pulses (more than 256) and display it onto the LCD. Can some body help?

Also I would like to get a list of the names used in coding of all the special registers. For example like PORTB, TC0, ADC_CH1.

Thanks for your help!

Jer Ford 4/29/2010

April 29, 2010
by JKITSON
JKITSON's Avatar

MONGO

Here is the code I used on the Tractor Pull Sled for setting up the serial port....

#define BAUDRATE 19200
#define UBRRVAL (47)

uart_init();
UBRR0L=47;
FILE uart_stream = FDEV_SETUP_STREAM(uart_putchar, uart_getchar, _FDEV_SETUP_RW);
stdin = stdout = &uart_stream;

The UBRROL=47 sets the serial port to 19200. This is used on both the Transmit and Rec. mcu's.

Hope this helps

Jim

April 30, 2010
by hevans
(NerdKits Staff)

hevans's Avatar

Hi Jer,

There are a few ways you can achieve what you are talking about. I think the simplest way to go about it is to use a normal pin change interrupt to detect the pulses, then just increment a 16 bit integer every time the interrupt fires. We go over pin change interrupts in our interrupts tutorial.

In general, I would recommend getting familiar with registers as you encounter (or need them), as I find this lets you get more familiar with them and really understand their purpose instead of getting lost in a very long list of register names. However if you do prefer to see them all at once the datasheet has a big table starting on page 343. Hope that answers your questions.

Humberto

May 01, 2010
by mongo
mongo's Avatar

Thanx Jim, I will give it a try once I get set back up. I haven't done anything with the NK since the laptop crashed and I am still working on getting Windows 7 to work with it.

I'll keep all posted as I make some progress.

May 01, 2010
by Jer
Jer's Avatar

Hi Humberto

Thanks for your response. What I would like to do is measure frequency up to 50KHz and if I use an interrupt the uC will be to busy to update the LCD and the keypad and all the other peripherals like DACs. So I think using the 16bit counter to count the external pulses and use an interrupt to flag the program when to read the 16bit value and the display it.

What I see in the doc’s is that the crystal is using the same pin as the 16bit counter input. Is it possible to use an external oscillator, at the same frequency, and feed it into the uC there by freeing up the 16bit counter input?

My project is a function generator that uses the uC to adjust all the analog control signals so the user only has to enter the function generator output setting via the keypad. I guess, if the 16bit counter can’t be used in this way I will just build an external counter.

Thanks for any other suggestions you may have.

Jer

May 02, 2010
by hevans
(NerdKits Staff)

hevans's Avatar

Hi Jer,

The input to the timer/counter unit is the clock pins. In general, the timers are used to count clock cycles. You could build an external timer, which would actually be pretty neat to see working. However I would suggest at least trying to keep track of the ticks using a pin change interrupt and a simple 16 bit variable. The interrupt handler itself should only be a few instructions long, running that at 50KHz should be possible. Remember your clock is running at 14.7MHz. 14.7MHz/50KHz gives you about 300 clock cycles between every firing of your 50KHz signal. This is now a whole lot, but it should be plenty to count the edges and write some info to the LCD. You are right that it wont leave that much time to do processing on that data, but you will run into that problem with an outside counter too.

Looking forward to hearing more about your project!

Humberto

May 05, 2010
by Jer
Jer's Avatar

Hey Humberto

Could please explain,in detale, how to write ISR vector code. Naming rules etc. The examples don't realy explain enough it seems like theres alot more to know and the it seems vage in the 168 uC pdf doc.

Also I rewrote the lcd.c to move the LCD data lines to port c tested and works to free up Ext. Int0 & Int1. Also I wrote code to count ext. pulses on the 16bit counter. Currently I have the code to display the count and clear the count on the pin change BUT I want it to work on ext-Int0 or Int1 so that it will fire the ISR on the fowling edge.

Thanks for all your help!

Jer

May 05, 2010
by Jer
Jer's Avatar

Please excuse my bad spelling. I'll use spell checking next time.

Jer

May 06, 2010
by hevans
(NerdKits Staff)

hevans's Avatar

Hi Jer,

There actually isn't that much to the ISR notation. The avr-libc interrupt documentation has a few examples, but it is pretty much as easy as:

ISR(vector_name){
    //interrtupt handler code goes here
}

There is a long list of vector names in the interrupt documentation I linked to above. It can sometimes be a bit tricky to map the actual interrupt you want to fire to the vector name, if you have a question about one of them don't hesitate to ask.

I've never personally used the external interrupts you are trying to use. I find the normal pin change interrupts get the job done just as well (and almost all the pins on the MCU can trigger it). If you want to use the External Interrupt pins make sure you set the EICRA and EIMSK registers correctly (page 68 and 69 of the datasheet).

Hope that helps.

Humberto

May 13, 2010
by mongo
mongo's Avatar

Hey Jim,

Got a question for you: I noticed a circuit between the NK and the 433 MHz transceiver in the photos. Whatsit do?

I have most of the circuit wired but there seems to be a signal problem in the data lines. The scope shows the inputs to be high and driven low, so I am guessing that that circuit is an inverter or driver of some kind?

Also, I am using a USB adapter to the other one but it has a different situation. Still working on that. (No normal serial ports on the new laptop)

Thanx for your help,

June 13, 2010
by mongo
mongo's Avatar

Well, After months of messing with it, I finally had to give up for now. After researching the components, here is what I found...

When I ordered the transceivers, they were supposed to be a Sure Electronics GP-GC010 433MHz pair. Looking at what I actually got, I thought thy were exactly that but there were no numbers that matched up to it. As it turns out, the components were substituted by the manufacturer and instead of the GP-GC010 units, I got a pair of CY2196R units. The specs were more forgiving, as they can run at the 5V supply range without having to reduce it to 4.2V max but after trying unsuccessfully over the last couple of weeks, I noticed there are two other CY2196xx models. CY2196T and CY2196TR. The differences? T = Transmitter, R = Receiver, TR = Transceiver. They shipped me two RECEIVERS. The only reason they have a data IN (RXD) pin is to program the channel. They do not transmit.

Needless to say, I am very disappointed with the deal I got and have notified the manufacturer of my discovery. chances are, I am out the $$ it cost me, as well as the time I have put into it.

June 13, 2010
by JKITSON
JKITSON's Avatar

HI MONGO

Sorry I missed your post on May 13. I hooked the xmtr directly to the mcu. The circuit you are looking at is probably the 4 volt regulator I had to put in. I just purchased a pair of 900 mhz units from Sure and they seem to work fine..I am using mine as one way units. Xmit from the nerdkits mcu to multiple rec. stations. Am about to try the multiple concept out next week.

Jim

August 08, 2010
by mongo
mongo's Avatar

OK, I had some time to cool off and read some more on these transceivers. It appears the cy2196R is both tx and rx. I did finally get the things to transmit... I think. Not sure, as I am still not getting anything from the other unit on the receive side.

I am testing the setup with the terminal program. I found that the signal from my USB to TTL converter needs the signal inverted to work on the input of the 2196. Now, I see activity on the RTS/CTS line so it must be doing something. The other unit is just sitting idle with power to the proper pins and an LED to give me a visual - but nothing happens.

Post a Reply

Please log in to post a reply.

Did you know that there are Power MOSFETs for switching big loads on and off? Learn more...