FUN AND NEW IDEAS
Go to bottomPage: 1234
TOPIC:
#1133
Distance Measurement using ZIlog 3 Months ago Karma: 0
Can someone help me in creating this code for zilog.??
I have an Arduino codes for this project but I can't understand how to modify this codes for using ZDS II.
Please help me... This is the code for arduino..


Ultrasonic sensor - Distance Measurement with arduino

# Define echoPin 2
# Define trigPin 3

# Define digit_4 12
# Define digit_3 11
# Define digit_2 10
# Define digit_1 9

# Define seven_segment_D 8
# Define seven_segment_C 7
# Define seven_segment_B 6
# Define seven_segment_A 5


int i,
int call,
int last;
void setup () {
Serial . Begin (9600);
pinMode (echoPin, INPUT );
pinMode (trigPin, OUTPUT );

for (i = 5; i <12: i + +)
pinMode (i, OUTPUT );

}

= pulse duration (echoPin, HIGH );
distance = distance/58;
value_write (distance);
}

void value_write ( int value) {
static int most1, most2, less1, less2;

less1 = value% 10;
value = value-less1;
value = value/10;
most1 = value% 10;
value = value-most1;
value = value/10;
less2 = value% 10;
most2 = 0;

segment_write (digit_1, less1);
segment_write (digit_2, most1);
segment_write (digit_3, less2);
segment_write (digit_4, most2);

}

void segment_write ( int digit, int value) {

if (digit == digit_1)
{

digitalWrite (digit_2, LOW );

digitalWrite (seven_segment_A, ((value & 0x01))? HIGH : LOW );
digitalWrite (seven_segment_B, ((value & 0x02))? HIGH : LOW );
digitalWrite (seven_segment_C, ((value & 0x04))? HIGH : LOW );
digitalWrite (seven_segment_D, ( (value & 0x08))? HIGH : LOW );

digitalWrite (digit_1, HIGH );
delay (5);

}
else if (digit == digit_2)
{

digitalWrite (digit_1, LOW );

digitalWrite (seven_segment_A, ((value & 0x01))? HIGH : LOW );
digitalWrite (seven_segment_B, ((value & 0x02))? HIGH : LOW );
digitalWrite (seven_segment_C, ((value & 0x04))? HIGH : LOW );
digitalWrite (seven_segment_D, ( (value & 0x08))? HIGH : LOW );

digitalWrite (digit_2, HIGH );
delay (5);
digitalWrite (digit_2, LOW );
}
else if (digit == digit_3)
{

digitalWrite (digit_2, LOW );
digitalWrite (digit_4, LOW );

digitalWrite (seven_segment_A, ((value & 0x01))? HIGH : LOW );
digitalWrite (seven_segment_B, ((value & 0x02))? HIGH : LOW );
digitalWrite (seven_segment_C, ((value & 0x04))? HIGH : LOW );
digitalWrite (seven_segment_D, ( (value & 0x08))? HIGH : LOW );

digitalWrite (digit_3, HIGH );
delay (5);
}
else if (digit == digit_4)
{
digitalWrite (digit_3, LOW );

digitalWrite (seven_segment_A, ((value & 0x01))? HIGH : LOW );
digitalWrite (seven_segment_B, ((value & 0x02))? HIGH : LOW );
digitalWrite (seven_segment_C, ((value & 0x04))? HIGH : LOW );
digitalWrite (seven_segment_D, ( (value & 0x08))? HIGH : LOW );

digitalWrite (digit_4, HIGH );
delay (5);
digitalWrite (digit_4, LOW );
}
}
graceshin00 (User)
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#1134
Re:Distance Measurement using ZIlog 3 Months ago Karma: 0
This looks like generic code for another purpose.

I have a distance module I haven't looked at yet. I think to start something like this, a schematic and datasheets are needed for the modules involved. Knowing where and how things are connected is required to control them.

Zilog makes processors and Arduino is a project board with one of a few different processors. ZDSII from zilog is available for many of their different processors.
mr (User)
Senior Boarder
Posts: 41
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#1135
Re:Distance Measurement using ZIlog 3 Months ago Karma: 0
Thanks for the advice mr..
my zilog is z8f042ahjsg

I want to use it as a distance measurement using an Ultra sonic sensor.. and will be display the distance in the 4 7 segments..
Thats as what I want to display...

I just don't know how to start my zilog codes...
I already have the ZDS II software..
graceshin00 (User)
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#1136
Re:Distance Measurement using ZIlog 3 Months ago Karma: 0
Look here for some sample application notes and source code "www.zilog.com/index.php?option=com_doc&Itemid=99"

Be sure to select Encore! / Encore! XP at the left to narrow the results for your processor. I thought AN0191-SC01 looked like it might be easy to study.
mr (User)
Senior Boarder
Posts: 41
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#1137
Re:Distance Measurement using ZIlog 2 Months, 4 Weeks ago Karma: 0
*Dear mr:

I think he's going to use Davantech SRF04 sensor or Parallax PING))) sensor or for his measurement, that are used here and here respectively.


*Dear graceshin00:

Does your trouble mainly concerning to a measurement part, a display part or both?

The sensors above are intelligent modules. They begin measurement by asserting a start pulse and they return a result pulse which width indicates the measured distance. The pulseIn() function of Arduino returns measured width of a pulse.

You can measure the duration of the result pulse if you can handle a timer thoughtfully. Especially in Z8, a Gated Mode of a timer module is more useful for you to measure the duration.

If the timer module is unfamiliar to you, I weakly recommend you to use a software loop as the easiest way.

Code:


#define PING_BIT 0x01;

unsigned int pulseIn(void)
{
    unsigned int count;
    PAOUT &= ~PING_BIT;

    // send a start pulse    
    PADD &= ~PING_BIT;                      // set PA1 to output
    PAOUT |= PING_BIT;                      // set PA1 to high
    for (count = 0; count < 999; count++);  // please adjust this constant
                                            //   to make start pulse = 5us
    PAOUT &= ~PING_BIT;                     // switch PA1 to low

    // measure a result pulse
    PADD |= PING_BIT;                       // switch PA1 to input
    while ((PAIN & PING_BIT) == 0);         // wait rising edge of a result pulse
    for (count = 0; PAIN & 0x01; count++);  // wait falling edge of the pulse

    return count;
}



The function returns a value which is directly proportional to the pulse duration.

If you want your Z8 to run another task like a robot control, I strongly recommend you to use Gated Mode of the timer.


*Attn: everyone

Hi!

Does anyone know ultrasonic-based range sensor that outputs analog voltage related to the measured distance? As mr insisted, I also think it is the most easiest way to apply AN0191 if he want his Z8 to run another task while the measurement. I found I2C-based range sensors, but I couldn't find an I2C in Z8F042A.


*Attn: Zilog

I think there's no updated I2C application note which is applicable to Encore XP series (premium peripheral set) -- e.g. ACK has been moved to I2CSTATE. I recently saw the question related to new I2C here.
Tomohiro HARAIKAWA (User)
Fresh Boarder
Posts: 8
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#1138
Re:Distance Measurement using ZIlog 2 Months, 4 Weeks ago Karma: 0
Thanks for the help mr..

Thanks Tomohiro..
But I'm just new in programming
i just dont know how to use codes in zilog..

I really need a codes for my project to develop.
graceshin00 (User)
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
Go to topPage: 1234