New Knight rider Flasher

Other Engineering Diciplines
RAT16F88
Lieutenant
Lieutenant
Posts: 72
Joined: Sat Nov 20, 2010 12:36 pm
Location: Inside a PIC

Re: New Knight rider Flasher

Post by RAT16F88 » Tue Aug 30, 2011 6:21 pm

:roll: :roll: :roll: :roll: :roll: :roll: :roll:

Smthing has gone wrong :mrgreen: :mrgreen: :mrgreen: :roll: :roll: :| :| :| :|


anyway gd wrk Rksk :biggrin: :biggrin: :biggrin: :biggrin: :biggrin: :biggrin:
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

Re: New Knight rider Flasher

Post by Rksk » Tue Aug 30, 2011 6:42 pm

RAT16F88 wrote::roll: :roll: :roll: :roll: :roll: :roll: :roll:

Smthing has gone wrong :mrgreen: :mrgreen: :mrgreen: :roll: :roll: :| :| :| :|


anyway gd wrk Rksk :biggrin: :biggrin: :biggrin: :biggrin: :biggrin: :biggrin:
Thank you.Thank you.

Have you the code for your posted video?

[ Post made via Mobile Device ] Image
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: New Knight rider Flasher

Post by Neo » Tue Aug 30, 2011 6:51 pm

Where is the wrong? does RaT lie?
Yours seems a bit slow to me. If you have used a 4MHz oscillator as in RAT's diagram, only thing I can guess is that your Oscillator setting in code. Try these.
  1. Normally in delay.h, you have #define PIC_CLK 4000000 //4Mhz so that the delay routines work correctly.
    You can use attached Delay routines and see whether that fix the problem.
    essentials.rar
    (3.86 KiB) Downloaded 469 times
    Edit: Changed the PIC_CLK to 4MHz
  2. If (1) doesn't seem to fix your problem, Insert this line on top of main() (if you are using HITECH C compiler).

    Code: Select all

    __CONFIG( XT & WDTDIS & PWRTDIS & BORDIS & LVPDIS & WRTEN & DEBUGDIS & UNPROTECT );
    Edit: Use HS for 8MHz and 16MHz (XT for 455KHz, 2MHz and 4MHz)
  3. If both (1) and (2) are not working, adjust the delay routines until you are satisfied. Just reduce the values (at present it is set to 300)
Last edited by Neo on Tue Aug 30, 2011 7:00 pm, edited 3 times in total.
Reason: Adjusted the delay.h to be 4MHz
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

Re: New Knight rider Flasher

Post by Rksk » Tue Aug 30, 2011 8:21 pm

Neo wrote:
Where is the wrong? does RaT lie?
Yours seems a bit slow to me. If you have used a 4MHz oscillator as in RAT's diagram, only thing I can guess is that your Oscillator setting in code. Try these.
  1. Normally in delay.h, you have #define PIC_CLK 4000000 //4Mhz so that the delay routines work correctly.
    You can use attached Delay routines and see whether that fix the problem.
    essentials.rar
    Edit: Changed the PIC_CLK to 4MHz
  2. If (1) doesn't seem to fix your problem, Insert this line on top of main() (if you are using HITECH C compiler).

    Code: Select all

    __CONFIG( XT & WDTDIS & PWRTDIS & BORDIS & LVPDIS & WRTEN & DEBUGDIS & UNPROTECT );
    Edit: Use HS for 8MHz and 16MHz (XT for 455KHz, 2MHz and 4MHz)
  3. If both (1) and (2) are not working, adjust the delay routines until you are satisfied. Just reduce the values (at present it is set to 300)
It's correct, my my one has a speed problem & your solution corrected it.

But my problem is not that. RaT's video's LEDs runing with a tail. But my video is not that, it's style is completly difference one. Watch both of videos carefully.


Thank you.

[ Post made via Mobile Device ] Image
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: New Knight rider Flasher

Post by Neo » Tue Aug 30, 2011 10:15 pm

But my problem is not that. RaT's video's LEDs runing with a tail. But my video is not that, it's style is completly difference one. Watch both of videos carefully.
Honestly I don't see any difference other than the speed. I guess the effect you see is due to the LEDs RAT has used and dark light on the video. May be my eyes are getting old just as me :lol:
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

Re: New Knight rider Flasher

Post by Rksk » Tue Aug 30, 2011 10:51 pm

Hmm...
Ho do I explain this???

RaT' Video - All the LEDs are lighted never!

My video - All the LEDs are lighted for two time in a cyle.

Thank you.

[ Post made via Mobile Device ] Image
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: New Knight rider Flasher

Post by Neo » Wed Aug 31, 2011 12:02 am

RaT' Video - All the LEDs are lighted never!
My video - All the LEDs are lighted for two time in a cyle.
You are correct. Obviously RAT was running a modified version. There should be two points where you will see all the LEDs light up according to the logic submitted in the first post.
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: New Knight rider Flasher

Post by Neo » Wed Aug 31, 2011 12:38 am

According to what I see, RAT only light up 4 LEDs at a time.
I was thinking to write a simplified logic for fun ;) Write the most optimised code (in C and ASM) is like my best hobby. when you also try on that, I'm sure you'll get lots of fun out of it.

Rksk, can you try these codes and let me know? Since I haven't either compiled them or run them, there can be issues (I don't have access to a PIC at the moment).

Code: Select all

void main() {

	int i = 1, side = 0; // side is set to left-to-right at first
	
	TRISB = 0; // Set PORT B as all outputs
	PORTB = 0; // Set all pins off

	while(1) {
	
		PORTB = (side == 0) ? ((0x00F0 << i) >> 8) : (0x0F00 >> i);
		
		if (i++ == 12){
			i = 1;
			side ^= 1; // XOR will switch sides
			Delay_ms(300); // Since we reached end, delay a bit more
		}
		else{
			Delay_ms(100);
		}
	}
}
If the above logic is complicated for you, try out the following one. Then I'm sure you'll be able to go for the first one which is more compact.

Code: Select all

void main() {

	int i;
	
	TRISB = 0; // Set PORT B as all outputs
	PORTB = 0; // Set all pins off

	while(1) {
	
		// Left to Right motion
		for (i=1; i <= 12; i++){
			PORTB = (0x00F0 << i) >> 8;
			Delay_ms(100);
		}

		Delay_ms(300); // Since we reached end, delay a bit more

		// Right to Left motion
		for (i=1; i <= 12; i++){
			PORTB = 0x0F00 >> i;
			Delay_ms(100);
		}

		Delay_ms(300); // Since we reached end, delay a bit more
	}
}
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

Re: New Knight rider Flasher

Post by Rksk » Wed Aug 31, 2011 5:28 pm

Neo wrote:According to what I see, RAT only light up 4 LEDs at a time.
I was thinking to write a simplified logic for fun ;) Write the most optimised code (in C and ASM) is like my best hobby. when you also try on that, I'm sure you'll get lots of fun out of it.

Rksk, can you try these codes and let me know? Since I haven't either compiled them or run them, there can be issues (I don't have access to a PIC at the moment).

Code: Select all

void main() {

	int i = 1, side = 0; // side is set to left-to-right at first
	
	TRISB = 0; // Set PORT B as all outputs
	PORTB = 0; // Set all pins off

	while(1) {
	
		PORTB = (side == 0) ? ((0x00F0 << i) >> 8) : (0x0F00 >> i);
		
		if (i++ == 12){
			i = 1;
			side ^= 1; // XOR will switch sides
			Delay_ms(300); // Since we reached end, delay a bit more
		}
		else{
			Delay_ms(100);
		}
	}
}
If the above logic is complicated for you, try out the following one. Then I'm sure you'll be able to go for the first one which is more compact.

Code: Select all

void main() {

	int i;
	
	TRISB = 0; // Set PORT B as all outputs
	PORTB = 0; // Set all pins off

	while(1) {
	
		// Left to Right motion
		for (i=1; i <= 12; i++){
			PORTB = (0x00F0 << i) >> 8;
			Delay_ms(100);
		}

		Delay_ms(300); // Since we reached end, delay a bit more

		// Right to Left motion
		for (i=1; i <= 12; i++){
			PORTB = 0x0F00 >> i;
			Delay_ms(100);
		}

		Delay_ms(300); // Since we reached end, delay a bit more
	}
}
It's cool Neo. I just compiled and simulated on Proteus. But only 1st one worked. I can't find error with 2nd one.

( my PC & JDM are doing crazy, they worked before and not working today. :shock: )

Thank you.

[ Post made via Mobile Device ] Image
john122
Corporal
Corporal
Posts: 6
Joined: Thu Feb 02, 2012 12:21 pm

Re: New Knight rider Flasher

Post by john122 » Thu Feb 02, 2012 5:58 pm

I like it very much.......
Post Reply

Return to “Other”