How do I get 18f452 pin 10 set as digital input?
Hello,
I've been going over the Data Sheet for the 18F452 trying to figure out how to set up PORTE.2 as a digital input and can't seem to make any head way with it. Could anyone suggest how I could accomplish this? I'm using PORTE.0 (pin 8) for my Lcd Register Select and PORTE.1 (pin 9) for the Lcd Enable. I'm using all the other in/out pins of the 452 and just need this last one to complete my project. Any help will be greatly appreciated.
Thanks
jessey
1 Attachment(s)
Still can't get pin 10 configured properly?
Quote:
Originally Posted by
Pic_User
Hi jessey,
looking forward to your code posting.
Thanks,
-Adam-
Hello Steve & Adam,
Sorry for taking so long to post my code but I've been pretty busy lately and it took a bit to go through the program and try and make the comments make sense. I just hope you can follow the flow of the program. If you have any questions then feel free to ask.
This program might be a little hard to follow because of all the Dummy variables that I used, I'm not sure if I'm using them correctly or if there's a better way of doing it but using the Dummy var's has saved me a lot of code space and the program seems to be working perfectly. Without them I definitely wouldn't have enough code space on my 18f452 for all the features I want to implement. There is still a lot I can do to save code space but its still a work in progress, I still have timing issues to resolve as well. Any comments or suggestions from anyone will be very much appreciated especially when it comes to using the Dummy variables.
I didn't have time to go through Darrels Strings routine to comment it properly but I can say it works great. When I get all the features in my program that I want then I'll finish the Strings by including an overview of the programs features and instructions on how to set it up. Its great to have a manual programmed into the chip, better than written instructions because you can't loose them. In Darrels Strings I can get 142 prints in GetInstructions1 alone, plus probably well over 100 in the other GetInstructions ones that I'm using. That's a great routine Darrel and I thank you again for it.
Oh, Steve I tried using SSPCON1=1 and I still can't seem to get pin 10 working as either a digital input or output. I tried it on a couple of different 452's with the same results?
Thanks
jessey
I'm sure its not the bread board
Quote:
Originally Posted by
skimask
Very well commented code indeed...BUT...the code, as a whole, looks entirely too over-written, over-designed, over-complicated, for the end result. This almost looks like something written for the Space Shuttle or something :)
Hi skimask,
Is the code that complicated? Yea I guess it is somewhat but what I was thinking to do when I was writing it, well for one code segment below:
The Dummy_Water_Valve holds the value of Water_Valve_1 to 6 for PORTB.2 to PORTB.7 so I use the Dummy_Water_Valve var to turn On or Off any of the 6 Water valves. The same thing applies to the Dummy_Nutrient_Valve variable but with different PORT pins of course.
I wanted to know if a Water Valve on PORTB.2 to PORTB.7 was involved in a watering cycle, so for that I'm using the Dummy_Water_Valve_Number variable. What happens is when a Moisture meter sends a request to start a watering cycle then its valve is turned on using the Dummy_Water_Valve var and at the same time the
Dummy_Water_Valve_Number var is set to Is_Watering so the program can use this var to know that there's an active watering cycle happening for that Moisture Meter. One way that the watering cycle can be turned Off is when the Moisture Meter that started the watering cycle sends a + signal for 2500ms to stop the watering and that sets Dummy_Water_Valve = Is_Turned_Off and at the same time the Dummy_Water_Valve_Number = Is_Not_Watering so the program knows what's going on. The other way of turning off the watering cycle is to use the Dummy_Off_Tm timer and that's pretty straight forward, its just a timer that when set it enables the auto Off, it counts up to a set time and shuts off the watering cycle using the exact same code segment that the Moisture meter uses to shut Off the watering cycle.
Using that logic then when we're implementing the watering cycle then we first check if the Dummy_Water_Valve_Number is watering and if so then if the Dummy_Water_Valve is On, then we implement the On_Time_counter or if the Dummy_Water_Valve is Off then we implement the Off_Time_Counter. Also (ELSE) if the Dummy_Water_Valve_Number is not watering then we just implement a Calibration Pause to maintain a one second time base for the timers.
That seems pretty basic to me but that's only one segment of the code. What part of the code were you having problems following or think is over done or complicated (not that it isn't somewhat complicated)? I'm sure that some of the other beginners here might be interested, I know I would if you have the time to try and follow the flow of the program. If you (or anyone else here for that mater) finds a part of the code that's confusing or redundant then I'll try and explain my logic for that part and or change it to flow better.
Back to the PortE.2 thing, I'm sure its not the bread board because when I set pin 10 to an output then I test a Led to make sure that its working then I touched the led directly on the port pin and it doesn't turn On/Off like it should. Real strange, I tried 4 different 452's and the same results, mind you they are all ones that are used but still? I'll try getting a few more new ones and play around with the config settings to see what results I get.
Thanks
jessey