Page 2 of 3

Re: New Knight rider Flasher

Posted: Tue Aug 30, 2011 6:21 pm
by RAT16F88
: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:

Re: New Knight rider Flasher

Posted: Tue Aug 30, 2011 6:42 pm
by Rksk
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

Re: New Knight rider Flasher

Posted: Tue Aug 30, 2011 6:51 pm
by Neo
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 484 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)

Re: New Knight rider Flasher

Posted: Tue Aug 30, 2011 8:21 pm
by Rksk
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

Re: New Knight rider Flasher

Posted: Tue Aug 30, 2011 10:15 pm
by Neo
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:

Re: New Knight rider Flasher

Posted: Tue Aug 30, 2011 10:51 pm
by Rksk
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

Re: New Knight rider Flasher

Posted: Wed Aug 31, 2011 12:02 am
by Neo
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.

Re: New Knight rider Flasher

Posted: Wed Aug 31, 2011 12:38 am
by Neo
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
	}
}

Re: New Knight rider Flasher

Posted: Wed Aug 31, 2011 5:28 pm
by Rksk
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

Re: New Knight rider Flasher

Posted: Thu Feb 02, 2012 5:58 pm
by john122
I like it very much.......