Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

mz80 And picbasic pro 2.60

Status
Not open for further replies.

ewreka

New Member
Hello everyone.

I want to programming a mini sumo robot,
i have pic 16f628a, mz80 sensor(e18 d50nk), cny 70 or qtr1A....etc

i am using pic basic pro 2.60.

my circuit working in the isis but i can't programming mz80.

how can i programing mz80 sensor(e18 d50nk).

Thank you
 
Last edited:
The documentation is appalling.

My best guess from looking at example Arduino code is that the output is an open collector digital signal.

So connect PIC ground to sensor ground, any port you choose to the yellow wire.

Put a pull-up (10k) on the chosen port to 5v.

Being an open collector output means the output line is never driven high, it will normally float to the pull-up voltage of 5V and read 1. When an obstacle is detected the line will be driven low and will then read 0.
 
Am I missing something??? The MZ80 is a infrared sensor with a switched output... What needs programming?? They have a trimpot on the rear to adjust sensitivity!!

If you need to simulate it in ISIS then a button will do!!
 
Thank you for reply.

dear mike_2545: i was looking for ardunio code but i cant understand.i am using picbasic pro 2.60 and thanks a lot for resistor suggestion.

dear Ian rogers: my isis simulation is does not work, because i cant programming pic for mz80 sensor.

my isis simulation(TRIAL):



my picbasic pro code:


@ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF

CMCON = 7
Trigger CON 5 ' trigger pulse = 10 uS
Scale CON $200 ' raw x 2.00 = uS
RawToIn CON 889 ' 1 / 73.746 (with **)
RawToCm CON 2257 ' 1 / 29.034 (with **)
IsHigh CON 1 ' for PULSOUT
IsLow CON 0
ULTRA_SONAR VAR PORTA.0

rawDist VAR Word
inches VAR Word
cm VAR Word

TRISA = 1
TRISB = 0
PORTB = 0
LOW ULTRA_SONAR
main:

GOSUB GET_SONAR
' get sensor value
inches = rawDist ** RawToIn ' inch'e dönü?tür
cm = rawDist ** RawToCm
' cm'ye dönü?tür
DO
IF (cm > 40) THEN GOTO LED1
IF (cm < 75) AND (CM > 40) THEN GOTO LED2
IF (cm < 40) THEN GOTO LED3
LOOP

GET_SONAR: ' make trigger 0-1-0
ULTRA_SONAR = IsLow
PULSOUT ULTRA_SONAR, Trigger
PULSIN ULTRA_SONAR, IsHigh, rawDist ' measure echo pulse
rawDist = rawDist */ Scale 'convert to uS
rawDist = rawDist / 2
RETURN

LED1:
PORTB = 0
HIGH PORTB.0
GOTO main

LED2:
PORTB = 0
HIGH PORTB.1
GOTO main

LED3:
PORTB = 0
HIGH PORTB.2
GOTO main
END

This code doesnot fork sharp :(
is this works for mz80? :S
 
hello.

I updated my code and the isis simulation,This still does not work.

my trial simulation:
VaJ1Zy.png


my picbasic pro code is here:

@ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF
INCLUDE "modedefs.bas"
DEFINE OSC 4
CMCON = 7

TRISA = 1
TRISB = 0

TRIGGER CON 5 ' trigger pulse = 10 uS
Scale CON $200 ' raw x 2.00 = uS
RawToIn CON 889 ' 1 / 73.746 (with **)
RawToCm CON 2257 ' 1 / 29.034 (with **)
IsHigh CON 1 ' for PULSOUT
IsLow CON 0

INC VAR WORD
CM VAR WORD
DIST VAR WORD
ULTRA VAR PORTA.0
rawDist VAR Word

PORTB = 0
low ultra

MAIN:

GOsub Get_Sonar1 ' get sensor value
INC = rawDist ** RawToIn ' inch'e dönü?tür
cm = rawDist ** RawToCm

DO
IF (CM > 20) THEN HIGH PORTB.0
IF (CM < 20) THEN LOW PORTB.0
LOOP

GOTO MAIN

Get_Sonar1: ' make trigger 0-1-0
ULTRA = IsLow
PULSOUT ULTRA, 1 ' sensor aktive
PULSIN ULTRA, IsHigh, rawDist ' measure echo pulse
rawDist = rawDist */ Scale ' convert to uS
rawDist = rawDist / 2
RETURN
' remove return trip
END
 
What does your DO...LOOP do? Whatever it is, it will do it a lot of times. In fact, so many times that the following statement GOTO MAIN will NEVER get executed.

So your program starts, gets a value from the sensor (it looks like it's trying to convert the input to centimeters). Then, depending on that value, loops infinitely, setting port.b high or low over and over again!

Is that what you intended?
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top