PWM out and PCINT together?

The new Edge ESC’s from Castle Creations have an extra wire that can be used to measure rpm, it toggles at every electrical commutation.

My Baby-O uses PB1 and OCR1A for pwm out between 2500 and 5000 and ICR for repeat 27500 (Fast pwm mode 14) (1 to 2 ms servo signal at a slightly higher frequency)

For measuring the rpm I set timer 1 as follows:

PCMSK1 |= (1 << PCINT13);   	//Pin Change Mask Register 
PCICR |= (1 << PCIE1);   		//Pin Change Interrupt Control Register

With the following ISR

ISR(PCINT1_vect)		// PC0..PC6 both rising and falling edge 
{
	cli();
	tcntn = TCNT1;
	if (tcntn >= tcntp)		// Discard when ICR overflow occurs
	{
		counts = ( tcntn - tcntp );
	}
	tcntp = tcntn;			// remember last passage for next time
	sei();
}

The output counts shows 2392 on the display and does not change with the rpm.
Do I miss something or am I searching a solution that is impossible on the same timer?

Hello.

Our Orangutan libraries have code for generating servo pulses and reading pulses (both using Timer 1). Can you try to write a simple program using our library functions to control the ESC and read pulses from it? If that still doesn’t go as expected, I think the next step would be to remove the ESC from the system and just try to measure the frequency of a known pulse train (such as one you generate yourself from the Baby Orangutan).

- Ben

That is what I intended to do, luckily you do not estimate it to be impossible.

In order not to mess up my working AVR4Studio environment still running on Vista I decided to make a fresh start on my new Windows 7 laptop.

According step 2 of Getting Started I installed Atmel Studio 6.1 and wanted to proceed with the Pololu AVR Bundle for Windows and get the following message:

De handtekening van pololu-avr-bundle-130508.exe is beschadigd of ongeldig, which I translate into The signature of pololu-avr-bundle-130508.exe is damaged or not valid.

Please advise.

The interrupt program works fine after all, I modified my servo timer to send out OCR1A of 5000 and ICR at 10000, the result showing 5000 in the receiving Baby-O.

There is a problem with the rpm data out signal cable of Castle Creations EDGE 50.

I still want to give the library a chance, can you look into the download problem?

Hello.

It is possible that your download got corrupted. Could you try downloading and installing it again? If the error persists, could you post a screenshot of the error message?

- Grant

see attachment

Meer informatie = More information
Verwijderen = remove
Downloads weergeven = Show downloads


Hello.

What piece of software is showing you that error message? If it is your web browser, which web browser are you using?

Regardless of what your web browser says about our AVR bundle, there should be an option to download it and run it anyway. Can you click on “Downloads weergeven”, locate the file in your Downloads folder, and run it?

–David

Try to run it directly leads to the same error message. I use explorer 10 on a Windows 7 with McAfee, no idea which application does the error message.

When I do the same operation on my Vista desktop there is no problem so it must be someting in combination with my laptop configuration.

I guess it will work if I transfer it on a usb stick.

Did you try closing Internet Explorer and just looking in your Downloads folder? The file is probably there. The error message you got really looks like it is coming from a web browser so I would be surprised if you got the exact same error message by double-clicking on the actual file outside of a web browser. Some screenshots to show what you are doing would help.

Once you get the program on your computer you should be able to run it just by double-clicking, but I would like to explore what might have caused the signature to fail. On the computer that is having the problem, please right-click on the AVR bundle executable and select Properties. There should be a Digital Signatures tab. Could you take a screenshot of that tab? Could you also click on the “Details” button to get details about our digitial signature, and take some screenshots of that tab so I can see what is going on?

–David

There proved to be nothing wrong with the Castle Creations rpm data out line, I forgot that you cannot connect a 3.3 Volt block wave to a 5 Volt Baby-O and expect the interrrupts to work correctly.

I installed a logic level converter and now I have my rpm out.

The download is in the download folder, I attached the screen dumps of the certificate. Here is a chance of learing some Dutch :wink:
Pololu certificate.docx (211 KB)

Thank you for the screenshots.

I was able to reproduce the problem here using Internet Explorer 10. The sentence “Deze digitale handtekening is in orde.” in your second screenshot must be the translation of “This digital signature is OK.” It seems like Windows itself is OK with the signature, but Internet Explorer does not like the signature on our bundle.

You should be able to just run the program and proceed with your project, but I will see if there is anything we can do to make Internet Explorer happy and avoid this issue in the future. Thank you for letting us know about the problem.

–David

The library installed succesfully, I created a project in Studio 6.1 using the library for the Baby-O ATmega328p
Building the example was succesful.

I already made an example blink LED program using Atmel Studio 6.1 without the library succesfully using an Atmel programmer so do not expect any problems here.

My program PWM out and PCINT together works succesfully, output is reliable and stable but higher than I expected, using SLO scope should provide me with a view of the incoming signal so I can verify if that is correct or whether I made an error in the rpm calculation.

I wired SLO-scope to my setup and here are the results, according Castle Creations this should be a block wave.

  1. Is this a limitation of SLO-scope or is the block not so square as advertised?
  2. The scale division factor was set to 1, is it correct that in total 10ms is shown on the lower screen

The signal is 3.3V and rather rough on the upper side, I re-wrote my code to work with raising edge only. This eliminates the need of a logic level converter.


Hello, erik46.

I do not think the shape you are seeing is due to the SLO-scope; I think I have seen cleaner waveforms from it but I probably never tested a 3.3 V square wave. Yes, you are looking at a total of 10 ms on the bottom part of the screen.

–David

I created a pulse with the help of a 2nd Baby-O This is on 5V and shows perfectly square. See attachment. 3.3V is too low for falling edge anyway in combination with the 5V Baby-O so I only use the raising edge. This can be done by adding the following statement to the interrupt routine:

if(PINC & (1<<DDC5)) // anything non-zero will be true and thus trigger the IF statement.
{
Measure time
} 

This shows 5860 rpm, my program saves the highest and lowest value which are shown on display after the motor is stopped, this shows a variation of 20 rpm which is quite good.