BasicMicro - Forums

www.basicmicro.com
It is currently Sat Feb 04, 2012 7:15 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: nano 18 cannot get input to work external switch
PostPosted: Wed Aug 11, 2010 1:29 pm 
Offline
Citizen

Joined: Tue Aug 10, 2010 3:42 pm
Posts: 15
I am having trouble to get a nano18 processor to work on input P3
I have tried p0 as well we are using an external switch tied to Vcc to p3 with a pulldown resistor for current limit. Our manual is on the way as we just recently purchased this hardware. we are using the basic micro development board. Everything else in our program appears to function correctly and the syntax manual is unclear on the input setup.



main

;***declare variables***
up_time_reading VAR word ;A/D reading for up time
dn_time_reading VAR word ; A/D reading for down time
sw_made VAR bit ; state of dead-man switch
relay_out var bit ;1=up, 0=down
up_counter VAR word ;ms counter of up-time
dn_counter VAR word ;ms counter of down time
toggleswitch var bit
Led_indic var bit


;***initialize chip***
pause 1000
clear

;***set up I/O pins***
sw_made = p3
relay_out = p12
led_indic = p1
low led_indic ; initial switch condition
high relay_out ; start position up
input p0
looper:
high led_indic
if sw_made=1 then

ADIN p8,up_time_reading
ADIN p9,dn_time_reading
up_time_reading=(up_time_reading*4)+1000
dn_time_reading=(dn_time_reading*5)-2000
endif
if sw_made=1 then
pause 100
high relay_out ; set p12 output high, turn relay on
up_counter=up_counter+100
pause 100
if up_counter>up_time_reading then
relay_out=0
endif

endif

if sw_made=0 then
pause 100
low relay_out
dn_counter=dn_counter+100
pause 100
if dn_counter>(dn_time_reading+up_time_reading)then
relay_out=1
endif
endif

goto looper
end


Top
 Profile  
 
 Post subject: Re: nano 18 cannot get input to work external switch
PostPosted: Wed Aug 11, 2010 10:20 pm 
Offline
Master

Joined: Sun Aug 17, 2008 5:26 pm
Posts: 798
Location: CA bay Area
Been there, done that, wanna see the scars?
Pin inputs are handled with the IN# command. So, your switch is read by doing

Code:
switch_made = IN0 ; or IN3, whatever
IF switch_made = 1 then goto This_Label
etc.


The manual for Studio is part of the HELP menu.
Have fun with your project. :)

_________________
kenjj
http://blog.basicmicro.com/
http://kjennejohn.wordpress.com/


Top
 Profile  
 
 Post subject: Re: nano 18 cannot get input to work external switch
PostPosted: Thu Aug 12, 2010 6:11 am 
Offline
Citizen

Joined: Tue Aug 10, 2010 3:42 pm
Posts: 15
thanks once I get to work I'll give that a try I had downloaded the software and the download only included the syntax manual and processor manuals also the manual for the development board did not see a manual under help on studio itself so we ordered the manuals posted on the site. under books. Were probably going to use this processor series (various sizes) for several projects.


Top
 Profile  
 
 Post subject: Re: nano 18 cannot get input to work external switch
PostPosted: Thu Aug 12, 2010 9:35 am 
Offline
Master

Joined: Sun Aug 17, 2008 5:26 pm
Posts: 798
Location: CA bay Area
The syntax manual in Studio is what I was refering to. That manual is specifically written for the AtomPro series, but the syntax and usage are largely the same between that and the Nano. The forum manual (still in progress) is to cover all of the series eventually.
Bad news: the two manuals they sell are no longer correct in several areas. BasicMicro has made several key changes to the compilers since the last printing. Syntax and timings and clocks have changed to some extent. And the parts ran on 16MHz or 20MHz crystals or resonators (still do), while the Nano uses an internal 8 MHz clock. This means lower top-end Baud rates and lower pulse widths, measured and produced. If the nano proves to be a little slow for you, just switch to the Atom Interpreter IC. Same chip, but it uses the external 20 MHz clock instead, a speed increase of 250%.

All this is not really a problem. There are user notes and app notes galore, in the downloads section and in the forums. So you have practical guides as how to use all the commands and modifiers. And you can always post a question here or contact BMicro's support center by email or by phone.

To my knowledge, several commercial outfits use the Atoms in their products and you should find them quite satisfactory for your application.
Later.

_________________
kenjj
http://blog.basicmicro.com/
http://kjennejohn.wordpress.com/


Top
 Profile  
 
 Post subject: Re: nano 18 cannot get input to work external switch
PostPosted: Fri Aug 13, 2010 10:59 pm 
Offline
Citizen

Joined: Tue Aug 10, 2010 3:42 pm
Posts: 15
I thank you for your prompt reply. I work for a company that often utilizes analog and serial applications. Bit of history is I personaly am a PLC industrial electronics tech that specialises in robotics plant automation, barcode readers etc, etc as due to 15 years of diverse work.
I now find myself working for a much smaller company but one that specializes in unique and specific design.
Some of the features that drew our attention to use of this chip involve the situable pinouts and shared signals, the lack of need to run a processor without any additional circuitry is also very handy.
I got the program working by removing any other variable declaration and replacing with straight (in3) for some reason variable rearrangement led to problems.
I have several questions as my company is looking into several applications with this chip.

1) What speed can the serial commucation handle if its transmitting a combination of 8 bit varied inputs and outputs? ( to better define if I were to multiplex several micro 18's running with a larger processor and send their individual input output status at worse case scenario, at all possible analog analog and PMW combinations Could I process 32 bits of input/output at max serial communicatin speed without bottlenecking ?

2) how many processors are cascadable if I am sending I\O state conditions ?
3) Does Micro atom recommend a serial multiplexor, in which I can handle that layer of input\outputs ( enough to convert say an 8 bit limitation to 32 bit)
4) what is tha max amperage a pin on any basic micro can handle ?
5) How easily is Mbasic migratable to basic and therefore C++ code? is is linkable????

I will have need of the other chip you referred to is there a link I can download the manual from as well as its data sheet? ( I have several real world and quoted designs that could benefict from this detail 8 hrz is simply not enough where I would need a full 20 mhz)


Top
 Profile  
 
 Post subject: Re: nano 18 cannot get input to work external switch
PostPosted: Fri Aug 13, 2010 11:39 pm 
Offline
Master

Joined: Sun Aug 17, 2008 5:26 pm
Posts: 798
Location: CA bay Area
I can't answer all knowledgeably, the folks at BasicMicro will have to handle the trickier questions. Here goes:
Mordred wrote:
1) What speed can the serial commucation handle if its transmitting a combination of 8 bit varied inputs and outputs?
The data sheet says the hardware USART can use Bauds up to 57600, transmit and recieve.

( to better define if I were to multiplex several micro 18's running with a larger processor and send their individual input output status at worse case scenario, as all possible analog.
How do you mean,"as all possible analog"? If you have a Master/Slave situation, where you are doing half-duplex, it's a matter of how fast the nano can turn around and start sending a stream in response. Of course using a USART interrupt speeds things up. And are you implementing a CRC, which adds to processing time?

Could I process 32 bits of input/output at max serial communicatin speed without bottlenecking ?
You can send 32 bit packets back and forth at 57600 Baud. In a half-duplex situation, the Nanos wait for the Master chip to query them, so no chance of bottlenecking. However, if there is a total communications time you have to observe, then you have to do the math of Number of Nanos * 32 bytes * time to transmit a byte at 57600 Baud, to determine if all this activity happens fast enough.
Of course, you could just broadcast a universal query to all Nanos at once, then use a strobe to each Nano one at a time to get their answer.


2) how many processors are cascadable if I am sending i\o state conditions ?
This might best be left to BMicro in the end, but I'd have to say: What are you using for the master processor?
If it has just a few mA of output on the COMMs pin, then it's a matter of how much current is necessary to successfully "wiggle" a PIC pin. If it takes a full mA (probably less), and 4 mA is what the master can provide, then the answer is "four". And you have to answer: is this all this local, as in kept in a small chassis, or spread to Hell all over a factory floor?


3) Does Micro atom recommend a serial multeplexor, in which I can handle that layer of input\outputs?
I'll let BMicro answer this.

4) what is tha max amperage a pin on any basic micro can handle ?
Shucks, what does the Nano data sheet say?

5) How easily is Mbsic migratable to basic and therefore C++ code? is is linkable????
Which MBasic? Which BASIC? Expand on that.
They claim C is usable, but I'll have to let them expalin that, as well as discuss linkage.


_________________
kenjj
http://blog.basicmicro.com/
http://kjennejohn.wordpress.com/


Top
 Profile  
 
 Post subject: Re: nano 18 cannot get input to work external switch
PostPosted: Sat Aug 14, 2010 10:11 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 784
Location: Temecula, CA
C is only available on AtomPro processors. There is no direct migration from Basic to C even on the AtomPro.

At 57600 the data through put is 5760 bytes per second. Thats theoretical. It's unlikely you will ever get that but you should be able to get close(around 5000 bytes/second). As for being able to do all the other processing necessary to generate around 5000 byte of data a second, thats the real question. I'm afraid "It depends" is the answer. Very simple code could generate more than 5000 bytes of data per second(eg you'd get bottle necked). Most code however isn't going to generate data fast enough to max out 57600. Not on a Nano since it's running at 8mhz.

_________________
Nathan Scherdin
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: nano 18 cannot get input to work external switch
PostPosted: Sat Aug 14, 2010 6:42 pm 
Offline
Citizen

Joined: Tue Aug 10, 2010 3:42 pm
Posts: 15
thanks for the responses, The last section of questions were in regard to a future project. Essentailly I'm looking at using one main processor then enough nano's to provide 32 bit inputs and outputs with 8 analog in and 8 analog out. I'll probably go with a larger version than the nano 18 to reduce chip counts but from the responses This certainly sounds do able. I may have to use the pro version of chips for its migration options to C code.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO